Commit 7128ed05 authored by Javier Segura's avatar Javier Segura Committed by Emmanuel Odeke

bytes: add examples of Equal and IndexByte

Change-Id: Ibf3179d0903eb443c89b6d886802c36f8d199898
Reviewed-on: https://go-review.googlesource.com/70933Reviewed-by: 's avatarEmmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 270a789c
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment