Documentation ¶
Index ¶
- Constants
- func ReadBytes(b *[]byte, n int) []byte
- func ReadInt(b *[]byte, bitSize int) (int, bool)
- func ReadInt16(b *[]byte) (int16, bool)
- func ReadInt24(b *[]byte) (int32, bool)
- func ReadInt32(b *[]byte) (int32, bool)
- func ReadInt64(b *[]byte) (int64, bool)
- func ReadInt8(b *[]byte) (int8, bool)
- func ReadReaderBytes(in io.Reader, n int) ([]byte, error)
- func ReadReaderUint16(in io.Reader) (uint16, error)
- func ReadReaderUint24(in io.Reader) (uint32, error)
- func ReadReaderUint32(in io.Reader) (uint32, error)
- func ReadReaderUint8(in io.Reader) (uint8, error)
- func ReadUint16(b *[]byte) (uint16, bool)
- func ReadUint24(b *[]byte) (uint32, bool)
- func ReadUint32(b *[]byte) (uint32, bool)
- func ReadUint64(b *[]byte) (uint64, bool)
- func ReadUint8(b *[]byte) (uint8, bool)
- func Skip(b *[]byte, n int) bool
- func SkipReader(in io.Reader, n int) error
- func WriteBytes(b *[]byte, bytes ...byte)
- func WriteInt(b *[]byte, v int, bitSize int)
- func WriteInt16(b *[]byte, v int16)
- func WriteInt24(b *[]byte, v int32)
- func WriteInt32(b *[]byte, v int32)
- func WriteInt64(b *[]byte, v int64)
- func WriteInt8(b *[]byte, v int8)
- func WriteUint16(b *[]byte, v uint16)
- func WriteUint24(b *[]byte, v uint32)
- func WriteUint32(b *[]byte, v uint32)
- func WriteUint64(b *[]byte, v uint64)
- func WriteUint8(b *[]byte, v uint8)
- func WriteWriterBytes(in io.Writer, bytes ...byte) error
- func WriteWriterUint16(in io.Writer, v uint16) error
- func WriteWriterUint24(in io.Writer, v uint32) error
- func WriteWriterUint32(in io.Writer, v uint32) error
- func WriteWriterUint8(in io.Writer, v uint8) error
- type Buffer
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) BytesPointer() *[]byte
- func (b *Buffer) Empty() bool
- func (b *Buffer) ReadBytes(n int) []byte
- func (b *Buffer) ReadGMTUnixTime32() (time.Time, bool)
- func (b *Buffer) ReadInt() (int, bool)
- func (b *Buffer) ReadInt16() (int16, bool)
- func (b *Buffer) ReadInt24() (int32, bool)
- func (b *Buffer) ReadInt32() (int32, bool)
- func (b *Buffer) ReadInt64() (int64, bool)
- func (b *Buffer) ReadInt8() (int8, bool)
- func (b *Buffer) ReadUint16() (uint16, bool)
- func (b *Buffer) ReadUint24() (uint32, bool)
- func (b *Buffer) ReadUint32() (uint32, bool)
- func (b *Buffer) ReadUint64() (uint64, bool)
- func (b *Buffer) ReadUint8() (uint8, bool)
- func (b *Buffer) ReadVector(bitSize int) ([]byte, bool)
- func (b *Buffer) Size() int
- func (b *Buffer) Skip(n int) bool
- func (b *Buffer) WriteBytes(bytes ...byte)
- func (b *Buffer) WriteGMTUnixTime32(time time.Time)
- func (b *Buffer) WriteInt(v int)
- func (b *Buffer) WriteInt16(v int16)
- func (b *Buffer) WriteInt24(v int32)
- func (b *Buffer) WriteInt32(v int32)
- func (b *Buffer) WriteInt64(v int64)
- func (b *Buffer) WriteInt8(v int8)
- func (b *Buffer) WriteRandom(n int)
- func (b *Buffer) WriteUint16(v uint16)
- func (b *Buffer) WriteUint24(v uint32)
- func (b *Buffer) WriteUint32(v uint32)
- func (b *Buffer) WriteUint64(v uint64)
- func (b *Buffer) WriteUint8(v uint8)
- func (b *Buffer) WriteVector(v []byte, bitSize int)
Constants ¶
const IntSize = intSize
IntSize is the size in bits of an int or uint value.
Variables ¶
This section is empty.
Functions ¶
func ReadBytes ¶
ReadBytes removes the first n bytes from b and returns it. If the read failed, returns nil.
func ReadInt ¶
ReadInt removes the first bytes (depends on bitSize) from b and returns it as an int. bitSize must be 8, 16, 24, 32 or 64.
func ReadInt16 ¶ added in v0.5.0
ReadInt16 removes the first bytes from b and returns it as an int16. The bool indicates whether the read was successful.
func ReadInt24 ¶ added in v0.5.0
ReadInt24 removes the first bytes from b and returns it as a int32. The bool indicates whether the read was successful.
func ReadInt32 ¶ added in v0.5.0
ReadInt32 removes the first bytes from b and returns it as an int32. The bool indicates whether the read was successful.
func ReadInt64 ¶ added in v0.5.0
ReadInt64 removes the first bytes from b and returns it as an int64. The bool indicates whether the read was successful.
func ReadInt8 ¶ added in v0.5.0
ReadInt8 removes the first byte from b and returns it as an int8. The bool indicates whether the read was successful.
func ReadReaderBytes ¶
ReadReaderBytes reads n byte from in. At the end of the file, io.EOF is returned.
func ReadReaderUint16 ¶
ReadReaderUint16 reads bytes from in and returns it as an uint16. At the end of the file io.EOF returned.
func ReadReaderUint24 ¶
ReadReaderUint24 reads bytes from in and returns it as an uint32. At the end of the file, io.EOF is returned.
func ReadReaderUint32 ¶
ReadReaderUint32 reads bytes from in and returns it as an uint32. At the end of the file io.EOF returned.
func ReadReaderUint8 ¶
ReadReaderUint8 reads a byte from in and returns is as an uint8. At the end of the file, io.EOF is returned.
func ReadUint16 ¶
ReadUint16 removes the first bytes from b and returns it as an uint16. The bool indicates whether the read was successful.
func ReadUint24 ¶
ReadUint24 removes the first bytes from b and returns it as a uint32. The bool indicates whether the read was successful.
func ReadUint32 ¶
ReadUint32 removes the first bytes from b and returns it as an uint32. The bool indicates whether the read was successful.
func ReadUint64 ¶ added in v0.5.0
ReadUint64 removes the first bytes from b and returns it as an uint64. The bool indicates whether the read was successful.
func ReadUint8 ¶
ReadUint8 removes the first byte from b and returns it as an uint8. The bool indicates whether the read was successful.
func SkipReader ¶
ReadReaderSkip skips n bytes in in. At the end of the file, io.EOF is returned.
func WriteBytes ¶
WriteBytes appends bytes at the end of b.
func WriteInt ¶
WriteInt append v at the end of b with size bitSize. bitSize must be 8, 16, 24, 32 or 64.
func WriteInt16 ¶ added in v0.5.0
WriteInt16 appends v at the end of b.
func WriteInt24 ¶ added in v0.5.0
WriteInt24 appends v at the end of b.
func WriteInt32 ¶ added in v0.5.0
WriteInt32 appends v at the end of b.
func WriteInt64 ¶ added in v0.5.0
WriteInt64 appends v at the end of b.
func WriteUint64 ¶ added in v0.5.0
WriteUint64 appends v at the end of b.
func WriteWriterBytes ¶
WriteWriterBytes appends v at the end of in.
func WriteWriterUint16 ¶
WriteWriterUint16 appends v at the end of in.
func WriteWriterUint24 ¶
WriteWriterUint24 appends v at the end of in.
func WriteWriterUint32 ¶
WriteWriterUint32 appends v at the end of in.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
func ReadAll ¶
ReadAll reads from r until an error or EOF and returns a Buffer from the data it read. A successful call returns err == nil, not err == EOF. Because ReadAll is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.
func (*Buffer) BytesPointer ¶
BytesPointer returns a pointer to the underlying byte slice.
func (*Buffer) ReadBytes ¶
ReadBytes removes the first n bytes from b and returns it. If the read failed, returns nil.
func (*Buffer) ReadGMTUnixTime32 ¶
ReadGMTUnixTime32 removes the first bytes from b and returns it as an unix time. The bool indicates whether the read was successful.
func (*Buffer) ReadInt ¶
ReadInt removes the first bytes (depends on IntSize) from b and returns it as an int.
func (*Buffer) ReadInt16 ¶ added in v0.6.0
ReadInt16 removes the first bytes from b and returns it as an int16. The bool indicates whether the read was successful.
func (*Buffer) ReadInt24 ¶ added in v0.6.0
ReadInt24 removes the first bytes from b and returns it as a int32. The bool indicates whether the read was successful.
func (*Buffer) ReadInt32 ¶ added in v0.6.0
ReadInt32 removes the first bytes from b and returns it as an int32. The bool indicates whether the read was successful.
func (*Buffer) ReadInt64 ¶ added in v0.6.0
ReadInt64 removes the first bytes from b and returns it as an int64. The bool indicates whether the read was successful.
func (*Buffer) ReadInt8 ¶ added in v0.6.0
ReadInt8 removes the first byte from b and returns it as an int8. The bool indicates whether the read was successful.
func (*Buffer) ReadUint16 ¶
ReadUint16 removes the first bytes from b and returns it as an uint16. The bool indicates whether the read was successful.
func (*Buffer) ReadUint24 ¶
ReadUint24 removes the first bytes from b and returns it as a uint32. The bool indicates whether the read was successful.
func (*Buffer) ReadUint32 ¶
ReadUint32 removes the first bytes from b and returns it as an uint32. The bool indicates whether the read was successful.
func (*Buffer) ReadUint64 ¶ added in v0.5.0
ReadUint64 removes the first bytes from b and returns it as an uint64. The bool indicates whether the read was successful.
func (*Buffer) ReadUint8 ¶
ReadUint8 removes the first byte from b and returns it as an uint8. The bool indicates whether the read was successful.
func (*Buffer) ReadVector ¶
ReadVector reads the length of bytes then the bytes itself. The length type is depend on bitSize (eg.: uint8, uint16, uint24, uint32, uint64). Therefore, bitSize must be 8/16/24/32/64. If bitSize is an invalid number, this function panics.
func (*Buffer) WriteBytes ¶
WriteBytes appends bytes at the end of b.
func (*Buffer) WriteGMTUnixTime32 ¶
WriteGMTUnixTime32 appends time to b in 32 bit unix format.
func (*Buffer) WriteInt ¶
WriteInt append v at the end of b with size bitSize. The number of bytes depends on IntSize.
func (*Buffer) WriteInt16 ¶ added in v0.5.0
WriteInt16 appends v at the end of b.
func (*Buffer) WriteInt24 ¶ added in v0.5.0
WriteInt24 appends v at the end of b.
func (*Buffer) WriteInt32 ¶ added in v0.5.0
WriteInt32 appends v at the end of b.
func (*Buffer) WriteInt64 ¶ added in v0.5.0
WriteInt64 appends v at the end of b.
func (*Buffer) WriteRandom ¶
WriteRandom appends n random bytes to b. If failed to read random, this function panics. This function gets random numbers from `crypto/rand` package.
func (*Buffer) WriteUint16 ¶
WriteUint16 appends v at the end of b.
func (*Buffer) WriteUint24 ¶
WriteUint24 appends v at the end of b.
func (*Buffer) WriteUint32 ¶
WriteUint32 appends v at the end of b.
func (*Buffer) WriteUint64 ¶ added in v0.5.0
WriteUint64 appends v at the end of b.
func (*Buffer) WriteUint8 ¶
WriteUint8 appends v at the end of b.
func (*Buffer) WriteVector ¶
WriteVector appends the length of bytes then the bytes itself. The length type is depend on bitSize (eg.: uint8, uint16, uint24, uint32, uint64). Therefore, bitSize must be 8/16/24/32/64. If bitSize is an invalid number, this function panics.