all: use strs.CutPrefix and strs.CutSuffix more
Updates places where we use HasPrefix + TrimPrefix to use the combined function. Updates #5309 Signed-off-by: Mihai Parparita <mihai@tailscale.com>
This commit is contained in:

committed by
Mihai Parparita

parent
41e1d336cc
commit
33520920c3
@ -32,6 +32,7 @@ import (
|
||||
"tailscale.com/metrics"
|
||||
"tailscale.com/net/tsaddr"
|
||||
"tailscale.com/types/logger"
|
||||
"tailscale.com/util/strs"
|
||||
"tailscale.com/version"
|
||||
)
|
||||
|
||||
@ -740,7 +741,7 @@ func structTypeSortedFields(t reflect.Type) []sortedStructField {
|
||||
// removed.
|
||||
func removeTypePrefixes(s string) string {
|
||||
for _, prefix := range prefixesToTrim {
|
||||
if trimmed := strings.TrimPrefix(s, prefix); trimmed != s {
|
||||
if trimmed, ok := strs.CutPrefix(s, prefix); ok {
|
||||
return trimmed
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user