github.com/webmafia/fast@v0.10.0/binary/stream_read_uint.go (about)

     1  package binary
     2  
     3  import (
     4  	"encoding/binary"
     5  )
     6  
     7  func (b *StreamReader) ReadUint8() (v uint8) {
     8  	v, b.err = b.ReadByte()
     9  	return
    10  }
    11  
    12  func (b *StreamReader) ReadUint16() uint16 {
    13  	var v [2]byte
    14  	b.err = b.ReadFull(v[:])
    15  	return binary.LittleEndian.Uint16(v[:])
    16  }
    17  
    18  func (b *StreamReader) ReadUint32() uint32 {
    19  	var v [4]byte
    20  	b.err = b.ReadFull(v[:])
    21  	return binary.LittleEndian.Uint32(v[:])
    22  }
    23  
    24  func (b *StreamReader) ReadUint64() uint64 {
    25  	var v [8]byte
    26  	b.err = b.ReadFull(v[:])
    27  	return binary.LittleEndian.Uint64(v[:])
    28  }
    29  
    30  func (b *StreamReader) ReadUint() uint {
    31  	return uint(b.ReadUint64())
    32  }
    33  
    34  func (b *StreamReader) ReadUvarint() (v uint64) {
    35  	v, b.err = binary.ReadUvarint(b.buf)
    36  	return
    37  }