aboutsummaryrefslogtreecommitdiff
path: root/src/strings
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2018-10-03 21:01:14 +0100
committerBrad Fitzpatrick <bradfitz@golang.org>2018-10-03 20:13:35 +0000
commit112f28defcbd8f48de83f4502093ac97149b4da6 (patch)
treedc91268f72f65c2ba28e95501a85156a1834f4e1 /src/strings
parentc91ce3cc7b13fce23edae94818e505f126036bdb (diff)
downloadgo-112f28defcbd8f48de83f4502093ac97149b4da6.tar.gz
go-112f28defcbd8f48de83f4502093ac97149b4da6.zip
io: export StringWriter
And start using it elsewhere in the standard library, removing the copies in the process. While at it, rewrite the io.WriteString godoc to be more clear, since it can now make reference to the defined interface. Fixes #27946. Change-Id: Id5ba223c09c19e5fb49815bd3b1bd3254fc786f3 Reviewed-on: https://go-review.googlesource.com/c/139457 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/strings')
-rw-r--r--src/strings/replace.go8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/strings/replace.go b/src/strings/replace.go
index dbda950194..9ddf5e1e3f 100644
--- a/src/strings/replace.go
+++ b/src/strings/replace.go
@@ -308,10 +308,6 @@ func (w *appendSliceWriter) WriteString(s string) (int, error) {
return len(s), nil
}
-type stringWriterIface interface {
- WriteString(string) (int, error)
-}
-
type stringWriter struct {
w io.Writer
}
@@ -320,8 +316,8 @@ func (w stringWriter) WriteString(s string) (int, error) {
return w.w.Write([]byte(s))
}
-func getStringWriter(w io.Writer) stringWriterIface {
- sw, ok := w.(stringWriterIface)
+func getStringWriter(w io.Writer) io.StringWriter {
+ sw, ok := w.(io.StringWriter)
if !ok {
sw = stringWriter{w}
}