]> Cypherpunks repositories - gostls13.git/commitdiff
bytes: add ReplaceAll example
authordupoxy <dupoxy@users.noreply.github.com>
Thu, 13 Dec 2018 18:52:17 +0000 (18:52 +0000)
committerIan Lance Taylor <iant@golang.org>
Thu, 13 Dec 2018 19:40:13 +0000 (19:40 +0000)
Change-Id: I36cc0b68a5a47ac78982b05118c58723c9c6648c
GitHub-Last-Rev: 0704d9569407d8b84d1ddcf845b759f7daa91ec1
GitHub-Pull-Request: golang/go#29203
Reviewed-on: https://go-review.googlesource.com/c/153842
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/bytes/example_test.go

index 4d5cdfa28095ef953067ee12b64e260038a2913a..6d328378fabdc48a99aff201905487aa12131521 100644 (file)
@@ -298,6 +298,12 @@ func ExampleReplace() {
        // moo moo moo
 }
 
+func ExampleReplaceAll() {
+       fmt.Printf("%s\n", bytes.ReplaceAll([]byte("oink oink oink"), []byte("oink"), []byte("moo")))
+       // Output:
+       // moo moo moo
+}
+
 func ExampleRunes() {
        rs := bytes.Runes([]byte("go gopher"))
        for _, r := range rs {