ipn/ipnserver: use strings.Cut

We now require Go 1.18.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder 2022-03-15 15:48:54 -07:00 committed by Josh Bleecher Snyder
parent 97a01b7b17
commit 9482576bb1

View File

@ -1179,7 +1179,7 @@ func loadExtraEnv() (env []string, err error) {
if line == "" || line[0] == '#' { if line == "" || line[0] == '#' {
continue continue
} }
k, v, ok := stringsCut(line, "=") k, v, ok := strings.Cut(line, "=")
if !ok || k == "" { if !ok || k == "" {
continue continue
} }
@ -1196,12 +1196,3 @@ func loadExtraEnv() (env []string, err error) {
} }
return env, nil return env, nil
} }
// stringsCut is Go 1.18's strings.Cut.
// TODO(bradfitz): delete this when we depend on Go 1.18.
func stringsCut(s, sep string) (before, after string, found bool) {
if i := strings.Index(s, sep); i >= 0 {
return s[:i], s[i+len(sep):], true
}
return s, "", false
}