io: add StringWriter interface type #27946
Labels
FrozenDueToAge
help wanted
NeedsFix
The path to resolution is known, but the work has not been done.
Proposal
Proposal-Accepted
Milestone
I propose that we export this interface:
Strictly speaking, this is not necessary. One can declare it elsewhere, or use it inline such as
w.(interface{ WriteString(string) (int, error) })
.However, I still think we should export it for a number of reasons:
Writer
andByteWriter
already, so I've expectedio.StringWriter
to exist many times in the past.If w implements a WriteString method
in the godoc can be a bit confusing if one is not used to that interface and signature.If w implements StringWriter
is much clearer.None of these points is a dealbreaker, but they do make learning and dealing with writers clunkier than it should be.
@dvyukov suggested exporting the interface in #21718, along with adding a
WriteByte
function. Note, however, that the issue was closed because it was decided that the function wasn't necessary. I agree with the decision. However, the interface should be considered separately.The text was updated successfully, but these errors were encountered: