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 <javascript:> > 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 message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.