github.com/webmafia/fast@v0.10.0/binary/buffer_write_int.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 int8 9 func (b *BufferWriter) WriteInt8(v int8) error { 10 b.WriteByte(uint8(v)) 11 return nil 12 } 13 14 // Write int16 15 func (b *BufferWriter) WriteInt16(v int16) error { 16 b.WriteUint16(uint16(v)) 17 return nil 18 } 19 20 // Write int32 21 func (b *BufferWriter) WriteInt32(v int32) error { 22 b.WriteUint32(uint32(v)) 23 return nil 24 } 25 26 // Write int64 27 func (b *BufferWriter) WriteInt64(v int64) error { 28 b.WriteUint64(uint64(v)) 29 return nil 30 } 31 32 // Write int 33 func (b *BufferWriter) WriteInt(v int) error { 34 b.WriteInt64(int64(v)) 35 return nil 36 } 37 38 func (b *BufferWriter) WriteVarint(v int64) error { 39 b.buf = binary.AppendVarint(b.buf, v) 40 return nil 41 }