aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/bytes/bytes.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/bytes/bytes.go')
-rw-r--r--libgo/go/bytes/bytes.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/libgo/go/bytes/bytes.go b/libgo/go/bytes/bytes.go
index ac8320f..9bfd88f 100644
--- a/libgo/go/bytes/bytes.go
+++ b/libgo/go/bytes/bytes.go
@@ -8,7 +8,7 @@ package bytes
import (
"unicode"
- "utf8"
+ "unicode/utf8"
)
// Compare returns an integer comparing the two byte arrays lexicographically.
@@ -88,6 +88,11 @@ func Count(s, sep []byte) int {
return n
}
+// Contains returns whether subslice is within b.
+func Contains(b, subslice []byte) bool {
+ return Index(b, subslice) != -1
+}
+
// Index returns the index of the first instance of sep in s, or -1 if sep is not present in s.
func Index(s, sep []byte) int {
n := len(sep)