mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-22 11:01:54 +00:00
all: use Go 1.18's strings.Cut
More remain. Change-Id: I6ec562cc1f687600758deae1c9d7dbd0d04004cb Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
1f22507c06
commit
61ee72940c
@@ -370,8 +370,8 @@ func writePromExpVar(w io.Writer, prefix string, kv expvar.KeyValue) {
|
||||
}
|
||||
if strings.HasPrefix(key, "labelmap_") {
|
||||
key = strings.TrimPrefix(key, "labelmap_")
|
||||
if i := strings.Index(key, "_"); i != -1 {
|
||||
label, key = key[:i], key[i+1:]
|
||||
if a, b, ok := strings.Cut(key, "_"); ok {
|
||||
label, key = a, b
|
||||
}
|
||||
}
|
||||
name := prefix + key
|
||||
@@ -541,9 +541,7 @@ func foreachExportedStructField(rv reflect.Value, f func(fieldOrJSONName, metric
|
||||
sf := t.Field(i)
|
||||
name := sf.Name
|
||||
if v := sf.Tag.Get("json"); v != "" {
|
||||
if i := strings.Index(v, ","); i != -1 {
|
||||
v = v[:i]
|
||||
}
|
||||
v, _, _ = strings.Cut(v, ",")
|
||||
if v == "-" {
|
||||
// Skip it, regardless of its metrictype.
|
||||
continue
|
||||
|
Reference in New Issue
Block a user