From 7128ed0501cc73a4d644ba1c510a152d680367a9 Mon Sep 17 00:00:00 2001 From: Javier Segura Date: Sun, 15 Oct 2017 23:20:10 +0200 Subject: [PATCH] bytes: add examples of Equal and IndexByte Change-Id: Ibf3179d0903eb443c89b6d886802c36f8d199898 Reviewed-on: https://go-review.googlesource.com/70933 Reviewed-by: Emmanuel Odeke Run-TryBot: Emmanuel Odeke TryBot-Result: Gobot Gobot --- src/bytes/example_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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) -- 2.48.1