]> Cypherpunks repositories - gostls13.git/commitdiff
bytes: add examples for TrimLeft and TrimRight
authorMichael Brandenburg <mbrandenburg@bolste.com>
Thu, 27 Jul 2017 03:25:37 +0000 (20:25 -0700)
committerJoe Tsai <thebrokentoaster@gmail.com>
Tue, 22 Aug 2017 21:31:54 +0000 (21:31 +0000)
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>

src/bytes/example_test.go

index 93972770ab2449a19e7eeb452999507603c4c397..43d19e186b3af69f3d384da350d7fb4b9305bb0b 100644 (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