github.com/webmafia/fast@v0.10.0/binary/stream_read_int.go (about) 1 package binary 2 3 import ( 4 "encoding/binary" 5 ) 6 7 func (b *StreamReader) ReadInt8() int8 { 8 var v uint8 9 v, b.err = b.ReadByte() 10 return int8(v) 11 } 12 13 func (b *StreamReader) ReadInt16() int16 { 14 var v [2]byte 15 b.err = b.ReadFull(v[:]) 16 return int16(binary.LittleEndian.Uint16(v[:])) 17 } 18 19 func (b *StreamReader) ReadInt32() int32 { 20 var v [4]byte 21 b.err = b.ReadFull(v[:]) 22 return int32(binary.LittleEndian.Uint32(v[:])) 23 } 24 25 func (b *StreamReader) ReadInt64() int64 { 26 var v [8]byte 27 b.err = b.ReadFull(v[:]) 28 return int64(binary.LittleEndian.Uint64(v[:])) 29 } 30 31 func (b *StreamReader) ReadInt() int { 32 return int(b.ReadInt64()) 33 } 34 35 func (b *StreamReader) ReadVarint() (v int64) { 36 v, b.err = binary.ReadVarint(b.buf) 37 return 38 }