internal/{gitfs,webtest}: use strings.Cut

Basic cut functionality is available in the standard library as of
Go 1.18, so today's supported Go versions (1.21 & 1.20) can use it.

Also delete cutAny since it was unused.

Change-Id: Iafce0197979d58f4ff4226fd5f640e925ab9b559
Reviewed-on: https://go-review.googlesource.com/c/website/+/531700
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/internal/gitfs/git.go b/internal/gitfs/git.go
index 41e3ef2..ff391f3 100644
--- a/internal/gitfs/git.go
+++ b/internal/gitfs/git.go
@@ -63,7 +63,7 @@
 	}
 	caps := make(map[string]string)
 	for _, line := range lines {
-		verb, args, _ := cut(line, "=")
+		verb, args, _ := strings.Cut(line, "=")
 		caps[verb] = args
 	}
 	if _, ok := caps["version 2"]; !ok {
@@ -147,7 +147,7 @@
 		return nil, fmt.Errorf("refs: parsing response: %v %d\n%s\n%s", err, len(data), hex.Dump(postbody), hex.Dump(data))
 	}
 	for _, line := range lines {
-		hash, rest, ok := cut(line, " ")
+		hash, rest, ok := strings.Cut(line, " ")
 		if !ok {
 			return nil, fmt.Errorf("refs: parsing response: invalid line: %q", line)
 		}
@@ -155,7 +155,7 @@
 		if err != nil {
 			return nil, fmt.Errorf("refs: parsing response: invalid line: %q", line)
 		}
-		name, _, _ := cut(rest, " ")
+		name, _, _ := strings.Cut(rest, " ")
 		refs = append(refs, ref{hash: h, name: name})
 	}
 	return refs, nil
diff --git a/internal/gitfs/pkt.go b/internal/gitfs/pkt.go
index d9be1d9..95b57b3 100644
--- a/internal/gitfs/pkt.go
+++ b/internal/gitfs/pkt.go
@@ -139,13 +139,3 @@
 func (w *pktLineWriter) Delim() {
 	w.b.WriteString("0001")
 }
-
-// cut looks for sep in s.
-// If sep is present, cut returns the text before and after sep, with ok = true.
-// If sep is missing, cut returns s, "", false.
-func cut(s, sep string) (before, after string, ok bool) {
-	if i := strings.Index(s, sep); i >= 0 {
-		return s[:i], s[i+len(sep):], true
-	}
-	return s, "", false
-}
diff --git a/internal/webtest/webtest.go b/internal/webtest/webtest.go
index 7c1e395..ef77276 100644
--- a/internal/webtest/webtest.go
+++ b/internal/webtest/webtest.go
@@ -161,7 +161,6 @@
 	"regexp"
 	"strings"
 	"testing"
-	"unicode/utf8"
 )
 
 // HandlerWithCheck returns an http.Handler that responds to each request
@@ -492,7 +491,7 @@
 	for text != "" {
 		lineno++
 		prevLine := line
-		line, text, _ = cut(text, "\n")
+		line, text, _ = strings.Cut(text, "\n")
 		if strings.HasPrefix(line, "#") {
 			continue
 		}
@@ -611,7 +610,7 @@
 				if kv == "" {
 					continue
 				}
-				k, v, ok := cut(kv, "=")
+				k, v, ok := strings.Cut(kv, "=")
 				if !ok {
 					lineno = cas.line // close enough
 					line = kv
@@ -650,24 +649,6 @@
 	return script, nil
 }
 
-// cut returns the result of cutting s around the first instance of sep.
-func cut(s, sep string) (before, after string, ok bool) {
-	if i := strings.Index(s, sep); i >= 0 {
-		return s[:i], s[i+len(sep):], true
-	}
-	return s, "", false
-}
-
-// cutAny returns the result of cutting s around the first instance of
-// any code point from any.
-func cutAny(s, any string) (before, after string, ok bool) {
-	if i := strings.IndexAny(s, any); i >= 0 {
-		_, size := utf8.DecodeRuneInString(s[i:])
-		return s[:i], s[i+size:], true
-	}
-	return s, "", false
-}
-
 // splitOneField splits text at the first space or tab
 // and returns that first field and the remaining text.
 func splitOneField(text string) (field, rest string) {