1
0
mirror of https://github.com/golang/go synced 2024-11-24 04:50:07 -07:00

bytes: add examples for TrimLeft and TrimRight

Change-Id: Ib6d94f185dd43568cf97ef267dd51a09f43a402f
Reviewed-on: https://go-review.googlesource.com/51391
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Michael Brandenburg 2017-07-26 20:25:37 -07:00 committed by Joe Tsai
parent d4dc26c0ad
commit 6cbe5c8ac3

View File

@ -281,11 +281,23 @@ func ExampleMap() {
// Output: 'Gjnf oevyyvt naq gur fyvgul tbcure...
}
func ExampleTrimLeft() {
fmt.Print(string(bytes.TrimLeft([]byte("+ 005400"), "+0 ")))
// Output:
// 5400
}
func ExampleTrimSpace() {
fmt.Printf("%s", bytes.TrimSpace([]byte(" \t\n a lone gopher \n\t\r\n")))
// Output: a lone gopher
}
func ExampleTrimRight() {
fmt.Print(string(bytes.TrimRight([]byte("453gopher8257"), "0123456789")))
// Output:
// 453gopher
}
func ExampleToUpper() {
fmt.Printf("%s", bytes.ToUpper([]byte("Gopher")))
// Output: GOPHER