diff options
| author | Javier Segura <javism@gmail.com> | 2017-10-15 23:20:10 +0200 |
|---|---|---|
| committer | Emmanuel Odeke <emm.odeke@gmail.com> | 2017-10-16 03:34:28 +0000 |
| commit | 7128ed0501cc73a4d644ba1c510a152d680367a9 (patch) | |
| tree | 0bed6739231cc111f0d79ddb43494fb810ce7a08 /src/bytes/example_test.go | |
| parent | 270a789c527bc6b43ed241f193d2d108b63fefa3 (diff) | |
| download | go-7128ed0501cc73a4d644ba1c510a152d680367a9.tar.xz | |
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>
Diffstat (limited to 'src/bytes/example_test.go')
| -rw-r--r-- | src/bytes/example_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/bytes/example_test.go b/src/bytes/example_test.go index 252be8c473..6a7ce59f55 100644 --- a/src/bytes/example_test.go +++ b/src/bytes/example_test.go @@ -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) |
