summaryrefslogtreecommitdiff
path: root/src/strings/example_test.go
Commit message (Collapse)AuthorAgeFilesLines
* strings: add a example for TrimFuncFrancisco Rojas2017-07-151-0/+8
| | | | | | | Change-Id: I9c0c601ec5957475e949dcc4a8c2116724d01215 Reviewed-on: https://go-review.googlesource.com/48961 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
* strings: add a example for Compare funcFrancisco Rojas2017-07-151-0/+10
| | | | | | | | Add a example for string.Compare that return the three possible results. Change-Id: I103cf39327c1868fb249538d9e22b11865ba4b70 Reviewed-on: https://go-review.googlesource.com/49011 Reviewed-by: Heschi Kreinick <heschi@google.com>
* strings: add example for IndexBytePablo Santiago Blum de Aguiar2017-07-151-0/+9
| | | | | | | | Change-Id: Ib6a59735381ce744553f1ac96eeb65a194c8da10 Reviewed-on: https://go-review.googlesource.com/48860 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* strings: add example for LastIndexAnyEvan Hicks2017-07-151-0/+10
| | | | | | | | Change-Id: I69d1359d8868d4c5b173e4d831e38cea7dfeb713 Reviewed-on: https://go-review.googlesource.com/48859 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* strings: add example for ContainsRuneKate Manson2017-07-151-0/+10
| | | | | | | Change-Id: I994f003c97a14d194df5f07dd217c0ff3b214741 Reviewed-on: https://go-review.googlesource.com/48874 Reviewed-by: Matt Layher <mdlayher@gmail.com> Run-TryBot: Matt Layher <mdlayher@gmail.com>
* strings: Add examples for HasPrefix and HasSuffixGaurish Sharma2015-10-231-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These methods didn't had any examples, so added them. Examples makes things more clear diff --git a/src/strings/example_test.go b/src/strings/example_test.go index 7243e16..b7763bb 100644 --- a/src/strings/example_test.go +++ b/src/strings/example_test.go @@ -223,3 +223,19 @@ func ExampleTrimPrefix() { fmt.Print("Hello" + s) // Output: Hello, world! } + +func ExampleHasPrefix() { + fmt.Println(strings.HasPrefix("hello", "hell")) + fmt.Println(strings.HasPrefix("hello", "heaven")) + // Output: + // true + // false +} + +func ExampleHasSuffix() { + fmt.Println(strings.HasSuffix("hello", "llo")) + fmt.Println(strings.HasSuffix("hello", "hell")) + // Output: + // true + // false +} Change-Id: I5d451c669bd05e19a2afc33ed2ec59b280c2c2d9 Reviewed-on: https://go-review.googlesource.com/12065 Reviewed-by: Russ Cox <rsc@golang.org>
* build: move package sources from src/pkg to srcRuss Cox2014-09-081-0/+225
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.