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

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