/goth-bytebuf

byte array operation tool

Primary LanguageGoOtherNOASSERTION

GoTH-bytebuf

make byte stream operation more easily

HOWTO

create empty byte buffer

    buf := EmptyByteBuf()

write string to byte buffer

    buf.WriteString("abcdef")

write int64 value to byte buffer

    buf.WriteInt64(int64(12345))

make a clone of current readable bytes

    clone := buf.Clone()

read 8 bytes array as int64 value from byte buffer

    buf := EmptyByteBuf()
    buf.WriteInt64(int64(12345)) // readable bytes len = 8
    v := buf.ReadInt64() // v = int64(12345)

skip 2 bytes and read 3 bytes of byte buffer

    bs := buf.Skip(2).ReadBytes(3)

reset byte buffer

    buf.Reset()