From: Francisco Rojas Date: Sat, 15 Jul 2017 20:51:58 +0000 (-0600) Subject: strings: add a example for TrimFunc X-Git-Tag: go1.9rc1~44 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b119ef154c1cc3bded16baff06143844bf1b28e1;p=gostls13.git strings: add a example for TrimFunc Change-Id: I9c0c601ec5957475e949dcc4a8c2116724d01215 Reviewed-on: https://go-review.googlesource.com/48961 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick --- diff --git a/src/strings/example_test.go b/src/strings/example_test.go index 473b8c3833..e9621522ef 100644 --- a/src/strings/example_test.go +++ b/src/strings/example_test.go @@ -234,6 +234,14 @@ func ExampleTrim() { // Output: ["Achtung! Achtung"] } +func ExampleTrimFunc() { + f := func(c rune) bool { + return !unicode.IsLetter(c) && !unicode.IsNumber(c) + } + fmt.Printf("[%q]", strings.TrimFunc(" Achtung1! Achtung2,...", f)) + // Output: ["Achtung1! Achtung2"] +} + func ExampleMap() { rot13 := func(r rune) rune { switch {