aboutsummaryrefslogtreecommitdiff
path: root/src/strings
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2019-04-03 19:38:11 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2019-04-03 20:15:58 +0000
commit61e0cac2988c29130417a323fd539604983854fb (patch)
treeac34fd8b936684928a3d775bc048e15389fb96cf /src/strings
parentf33b67b870208071a737768a6165198ccf340ec0 (diff)
downloadgo-61e0cac2988c29130417a323fd539604983854fb.tar.gz
go-61e0cac2988c29130417a323fd539604983854fb.zip
strings: document that NewReplacer can panic
Fixes #31233 Change-Id: I2831d5e6532d3f4ed7eb99af5d6e0e1a41ebac9a Reviewed-on: https://go-review.googlesource.com/c/go/+/170624 Reviewed-by: Andrew Bonventre <andybons@golang.org>
Diffstat (limited to 'src/strings')
-rw-r--r--src/strings/replace.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/strings/replace.go b/src/strings/replace.go
index ace0b8d646..ccab1fb861 100644
--- a/src/strings/replace.go
+++ b/src/strings/replace.go
@@ -26,6 +26,8 @@ type replacer interface {
// NewReplacer returns a new Replacer from a list of old, new string
// pairs. Replacements are performed in the order they appear in the
// target string, without overlapping matches.
+//
+// NewReplacer panics if given an odd number of arguments.
func NewReplacer(oldnew ...string) *Replacer {
if len(oldnew)%2 == 1 {
panic("strings.NewReplacer: odd argument count")