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

     1  // Borrowed from jsoniter (https://github.com/json-iterator/go)
     2  package binary
     3  
     4  import (
     5  	"encoding/binary"
     6  )
     7  
     8  // Write uint8
     9  func (b *BufferWriter) WriteUint8(v uint8) error {
    10  	return b.WriteByte(v)
    11  }
    12  
    13  // Write uint16
    14  func (b *BufferWriter) WriteUint16(v uint16) error {
    15  	b.buf = binary.LittleEndian.AppendUint16(b.buf, v)
    16  	return nil
    17  }
    18  
    19  // Write uint32
    20  func (b *BufferWriter) WriteUint32(v uint32) error {
    21  	b.buf = binary.LittleEndian.AppendUint32(b.buf, v)
    22  	return nil
    23  }
    24  
    25  // Write uint64
    26  func (b *BufferWriter) WriteUint64(v uint64) error {
    27  	b.buf = binary.LittleEndian.AppendUint64(b.buf, v)
    28  	return nil
    29  }
    30  
    31  // Write uint
    32  func (b *BufferWriter) WriteUint(v uint) error {
    33  	return b.WriteUint64(uint64(v))
    34  }
    35  
    36  func (b *BufferWriter) WriteUvarint(v uint64) error {
    37  	b.buf = binary.AppendUvarint(b.buf, v)
    38  	return nil
    39  }