-
Notifications
You must be signed in to change notification settings - Fork 668
Remove type parameters from go names #2343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -92,7 +92,7 @@ func (l *Limits) RegisterFlags(f *flag.FlagSet) { | |||
f.IntVar(&l.MaxProfileStacktraceSamples, "validation.max-profile-stacktrace-samples", 16000, "Maximum number of samples in a profile. 0 to disable.") | |||
f.IntVar(&l.MaxProfileStacktraceSampleLabels, "validation.max-profile-stacktrace-sample-labels", 100, "Maximum number of labels in a profile sample. 0 to disable.") | |||
f.IntVar(&l.MaxProfileStacktraceDepth, "validation.max-profile-stacktrace-depth", 1000, "Maximum depth of a profile stacktrace. Profiles are not rejected instead stacktraces are truncated. 0 to disable.") | |||
f.IntVar(&l.MaxProfileSymbolValueLength, "validation.max-profile-symbol-value-length", 1024, "Maximum length of a profile symbol value (labels, function names and filenames, etc...). Profiles are not rejected instead symbol values are truncated. 0 to disable.") | |||
f.IntVar(&l.MaxProfileSymbolValueLength, "validation.max-profile-symbol-value-length", 65535, "Maximum length of a profile symbol value (labels, function names and filenames, etc...). Profiles are not rejected instead symbol values are truncated. 0 to disable.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func DropGoTypeParameters(input string) string { | ||
matchesIndices := goStructTypeParameterRegex.FindAllStringIndex(input, -1) | ||
if len(matchesIndices) == 0 { | ||
return input | ||
} | ||
var modified strings.Builder | ||
prevEnd := 0 | ||
for _, indices := range matchesIndices { | ||
start, end := indices[0], indices[1] | ||
modified.WriteString(input[prevEnd:start] + "[...]") | ||
prevEnd = end | ||
} | ||
modified.WriteString(input[prevEnd:]) | ||
return modified.String() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we don't know if it is a Go profile / node, therefore the function is applied to all nodes. ReplaceAllString
would look better here but it allocates a new string.
I'm also not sure if there might be more than one group of type parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #2241.
Replaces Go type parameters with ellipses as it was before go 1.21.0.