]> Cypherpunks repositories - gostls13.git/commitdiff
strings: add example for IndexByte
authorPablo Santiago Blum de Aguiar <scorphus@gmail.com>
Sat, 15 Jul 2017 18:13:45 +0000 (12:13 -0600)
committerIan Lance Taylor <iant@golang.org>
Sat, 15 Jul 2017 20:38:29 +0000 (20:38 +0000)
Change-Id: Ib6a59735381ce744553f1ac96eeb65a194c8da10
Reviewed-on: https://go-review.googlesource.com/48860
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/strings/example_test.go

index fa34a8099f6bad5eeed0ad3e3324fe0c59519933..d9e31ea770484562a2e1f1881cc79e01dc28fd73 100644 (file)
@@ -119,6 +119,15 @@ func ExampleIndexAny() {
        // -1
 }
 
+func ExampleIndexByte() {
+       fmt.Println(strings.IndexByte("golang", 'g'))
+       fmt.Println(strings.IndexByte("gophers", 'h'))
+       fmt.Println(strings.IndexByte("golang", 'x'))
+       // Output:
+       // 0
+       // 3
+       // -1
+}
 func ExampleIndexRune() {
        fmt.Println(strings.IndexRune("chicken", 'k'))
        fmt.Println(strings.IndexRune("chicken", 'd'))