From b119ef154c1cc3bded16baff06143844bf1b28e1 Mon Sep 17 00:00:00 2001 From: Francisco Rojas Date: Sat, 15 Jul 2017 14:51:58 -0600 Subject: [PATCH] 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 --- src/strings/example_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) 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 { -- 2.50.0