Closed
Description
What version of Go are you using (go version
)?
1.9beta1
What did you do?
In my code, I'm implementing fmt.Formatter
.
In order to write a string
to the fmt.State
, I'm calling io.WriteString()
.
I know that this function has an optimization that allows to call WriteString()
if w
implements it.
Sadly, in my case the "real" type of fmt.State
is fmt.pp
.
fmt.pp
only has Write()
.
What did you expect to see?
I think we should add:
func (p *pp) WriteString(s string) (ret int, err error) {
p.buf.WriteString(s)
return len(s), nil
}
in my case, it greatly improve performance and reduces memory allocation.
We could also implement WriteByte()
and WriteRune()
, since fmt.buffer
has these methods.