1
0
mirror of https://github.com/golang/go synced 2024-11-18 19:54:44 -07:00

bytes, strings: use "reports whether" in HasPrefix and HasSuffix

Update the doc comments to use the more idiomatic and common phrase
"reports whether" instead of "tests whether".

Change-Id: I2b7f8cce2d192f66e296ebaa9b37f37e8276b4ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/524898
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Matthew Dempsky 2023-08-31 19:15:19 -07:00 committed by Gopher Robot
parent 7a4787d12a
commit 62fb281cf7
2 changed files with 4 additions and 4 deletions

View File

@ -552,12 +552,12 @@ func Join(s [][]byte, sep []byte) []byte {
return b
}
// HasPrefix tests whether the byte slice s begins with prefix.
// HasPrefix reports whether the byte slice s begins with prefix.
func HasPrefix(s, prefix []byte) bool {
return len(s) >= len(prefix) && Equal(s[0:len(prefix)], prefix)
}
// HasSuffix tests whether the byte slice s ends with suffix.
// HasSuffix reports whether the byte slice s ends with suffix.
func HasSuffix(s, suffix []byte) bool {
return len(s) >= len(suffix) && Equal(s[len(s)-len(suffix):], suffix)
}

View File

@ -458,12 +458,12 @@ func Join(elems []string, sep string) string {
return b.String()
}
// HasPrefix tests whether the string s begins with prefix.
// HasPrefix reports whether the string s begins with prefix.
func HasPrefix(s, prefix string) bool {
return len(s) >= len(prefix) && s[0:len(prefix)] == prefix
}
// HasSuffix tests whether the string s ends with suffix.
// HasSuffix reports whether the string s ends with suffix.
func HasSuffix(s, suffix string) bool {
return len(s) >= len(suffix) && s[len(s)-len(suffix):] == suffix
}