[go-nuts] Re: int64 -> []byte writing 9 bytes?

2017-02-27 Thread Guillermo Estrada
Thanks! I guess I missed them cause of the ordering variables being on the very top and ByteOrder interface being the last. I knew there had to be a way and I was missing something. On Monday, February 27, 2017 at 12:51:08 PM UTC-6, howar...@gmail.com wrote: > > Look a little further down -

[go-nuts] Re: int64 -> []byte writing 9 bytes?

2017-02-27 Thread Guillermo Estrada
On Monday, February 27, 2017 at 12:48:53 PM UTC-6, howar...@gmail.com wrote: > > You are missing that it is encoding. Specifically, using VarInt is asking > for Variable integer encoding: > https://developers.google.com/protocol-buffers/docs/encoding#varints > > The important bit here is that

[go-nuts] Re: int64 -> []byte writing 9 bytes?

2017-02-27 Thread Guillermo Estrada
Thanks a lot! This works as expected, I think functions for BigEndian and LittleEndian should be documented or at least referenced in the binary documentation. import ( "encoding/binary" "fmt" "time" ) func main() { t := time.Now() b1 := make([]byte, 8) b2 := make([]byte, 8)

[go-nuts] Re: int64 -> []byte writing 9 bytes?

2017-02-27 Thread howardcshaw
Look a little further down - they are documented in the ByteOrder type. A ByteOrder specifies how to convert byte sequences into 16-, 32-, or 64-bit unsigned integers. type ByteOrder interface { Uint16([]byte ) uint16

[go-nuts] Re: int64 -> []byte writing 9 bytes?

2017-02-27 Thread howardcshaw
You are missing that it is encoding. Specifically, using VarInt is asking for Variable integer encoding: https://developers.google.com/protocol-buffers/docs/encoding#varints The important bit here is that the Varint stores 7-bits of data and 1-bit of metadata in each byte (the metadata being

[go-nuts] Re: int64 -> []byte writing 9 bytes?

2017-02-27 Thread Guillermo Estrada
On Monday, February 27, 2017 at 12:41:43 PM UTC-6, zeebo wrote: > > You're using the variable width encoding. The number of bytes of a > variable width encoded int64 will depend on the magnitude of the value. If > you use binary.BigEndian or binary.LittleEndian you can use the > *PutUint64*

[go-nuts] Re: int64 -> []byte writing 9 bytes?

2017-02-27 Thread zeebo
You're using the variable width encoding. The number of bytes of a variable width encoded int64 will depend on the magnitude of the value. If you use binary.BigEndian or binary.LittleEndian you can use the PutUint64 method which will always be 8 bytes. On Monday, February 27, 2017 at 11:27:07