aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/bytes
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2011-11-04 17:46:52 +1100
committerAndrew Gerrand <adg@golang.org>2011-11-04 17:46:52 +1100
commit1a4402a1feab4a8592986a3b3675a3261667e19c (patch)
tree447a3e1d1d9027a8f4bc113273d1c260cce56ccb /src/pkg/bytes
parent632a2c59b12b525edac2fffa4ddd57b3de068707 (diff)
downloadgo-1a4402a1feab4a8592986a3b3675a3261667e19c.tar.xz
bytes: add Contains function
R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5349041
Diffstat (limited to 'src/pkg/bytes')
-rw-r--r--src/pkg/bytes/bytes.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/pkg/bytes/bytes.go b/src/pkg/bytes/bytes.go
index ac8320fe6b..f7f2f03cd7 100644
--- a/src/pkg/bytes/bytes.go
+++ b/src/pkg/bytes/bytes.go
@@ -88,6 +88,11 @@ func Count(s, sep []byte) int {
return n
}
+// Contains returns whether subslice is within b.
+func Contains(b, subslice []string) 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)