diff options
Diffstat (limited to 'src/pkg/strings/example_test.go')
-rw-r--r-- | src/pkg/strings/example_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/pkg/strings/example_test.go b/src/pkg/strings/example_test.go index 733caf5f2..36e0a42fb 100644 --- a/src/pkg/strings/example_test.go +++ b/src/pkg/strings/example_test.go @@ -179,3 +179,19 @@ func ExampleToLower() { fmt.Println(strings.ToLower("Gopher")) // Output: gopher } + +func ExampleTrimSuffix() { + var s = "Hello, goodbye, etc!" + s = strings.TrimSuffix(s, "goodbye, etc!") + s = strings.TrimSuffix(s, "planet") + fmt.Print(s, "world!") + // Output: Hello, world! +} + +func ExampleTrimPrefix() { + var s = "Goodbye,, world!" + s = strings.TrimPrefix(s, "Goodbye,") + s = strings.TrimPrefix(s, "Howdy,") + fmt.Print("Hello" + s) + // Output: Hello, world! +} |