You almost never want bytes.NewBuffer. Its only purpose is to load a buffer
with existing data to be read using Buffer.Read.
-rob
On Tue, Oct 10, 2017 at 8:14 PM, wrote:
> Oh yes, thank you. I totally missed that, thinking the bytes.Buffer was
> preallocated with 4 bytes, instead i filled it w
Oh yes, thank you. I totally missed that, thinking the bytes.Buffer was
preallocated with 4 bytes, instead i filled it with 4x0 bytes
Le mardi 10 octobre 2017 10:59:56 UTC+2, Ian Davis a écrit :
>
>
>
>
> On Tue, 10 Oct 2017, at 09:51 AM, aurelien...@gmail.com
> wrote:
>
>
> func main() {
> buf
On Tue, 10 Oct 2017, at 09:51 AM, aurelien.rain...@gmail.com wrote:
>
> func main() {
> buf := bytes.NewBuffer(make([]byte, 4))
> buf.WriteString("1234")
These two lines result in a string with 4 null bytes followed by 1234.
Just use buf := &bytes.Buffer{}
Ian
--
You received this mess