Closed n10v closed 8 years ago
So, what do you think of it?
@bogem How would we use the AppendX
functions of strconv
package with a private underlying byte slice ?
@wI2L By creating a new method:
func (b *ByteBuffer) AppendX(v X) {
b.buf = strconv.AppendX(b.buf, v)
}
I think, it's better to use private underlying bytes slice
Probably yes, but it is too late to change public API, since it may break existing code. I'd recommend forking the package and integrate these changes there.
@bogem In my use case, having a public underlying byte slice allow me to pass it to a chain of function in an append-like serialization process, which is effectively very convenient. The serialization functions takes a []byte
as argument and return it, so I can either use this package if I want something optimized, or simply pass a new byte slice from scratch.
Others methods of the buffer (Write
, WriteByte
..) are only a convenience, so as your AppendX
proposal would be.
Like @valyala said, its too late to change it, but honestly I can't see how "it's better" to have a private underlying byte.
I think, it's better to use private underlying bytes slice