]> Cypherpunks repositories - gostls13.git/commitdiff
bytes: add examples of Equal and IndexByte
authorJavier Segura <javism@gmail.com>
Sun, 15 Oct 2017 21:20:10 +0000 (23:20 +0200)
committerEmmanuel Odeke <emm.odeke@gmail.com>
Mon, 16 Oct 2017 03:34:28 +0000 (03:34 +0000)
Change-Id: Ibf3179d0903eb443c89b6d886802c36f8d199898
Reviewed-on: https://go-review.googlesource.com/70933
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/bytes/example_test.go

index 252be8c473d71f60ba341dda2f585dcf88197f57..6a7ce59f55b84d0564e509cb6884efbd7d655250 100644 (file)
@@ -153,6 +153,14 @@ func ExampleCount() {
        // 5
 }
 
+func ExampleEqual() {
+       fmt.Println(bytes.Equal([]byte("Go"), []byte("Go")))
+       fmt.Println(bytes.Equal([]byte("Go"), []byte("go")))
+       // Output:
+       // true
+       // false
+}
+
 func ExampleEqualFold() {
        fmt.Println(bytes.EqualFold([]byte("Go"), []byte("go")))
        // Output: true
@@ -188,6 +196,14 @@ func ExampleIndex() {
        // -1
 }
 
+func ExampleIndexByte() {
+       fmt.Println(bytes.IndexByte([]byte("chicken"), byte('k')))
+       fmt.Println(bytes.IndexByte([]byte("chicken"), byte('g')))
+       // Output:
+       // 4
+       // -1
+}
+
 func ExampleIndexFunc() {
        f := func(c rune) bool {
                return unicode.Is(unicode.Han, c)