From: Javier Segura Date: Sun, 15 Oct 2017 21:20:10 +0000 (+0200) Subject: bytes: add examples of Equal and IndexByte X-Git-Tag: go1.10beta1~709 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7128ed0501cc73a4d644ba1c510a152d680367a9;p=gostls13.git 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 --- 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)