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

bytes: add examples of Equal and IndexByte

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>
This commit is contained in:
Javier Segura 2017-10-15 23:20:10 +02:00 committed by Emmanuel Odeke
parent 270a789c52
commit 7128ed0501

View 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)