From 112f28defcbd8f48de83f4502093ac97149b4da6 Mon Sep 17 00:00:00 2001 From: Daniel Martí Date: Wed, 3 Oct 2018 21:01:14 +0100 Subject: io: export StringWriter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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í Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/strings/replace.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/strings/replace.go') 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} } -- cgit v1.3