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:
Brad Fitzpatrick
2022-03-16 14:25:31 -07:00
committed by Brad Fitzpatrick
parent 1f22507c06
commit 61ee72940c
7 changed files with 17 additions and 31 deletions

View File

@@ -185,10 +185,8 @@ func NumLabels(hostname string) int {
// FirstLabel returns the first DNS label of hostname.
func FirstLabel(hostname string) string {
if i := strings.IndexByte(hostname, '.'); i != -1 {
return hostname[:i]
}
return hostname
first, _, _ := strings.Cut(hostname, ".")
return first
}
var separators = map[byte]bool{