write.go (846B)
1 package pgio 2 3 import "encoding/binary" 4 5 func AppendUint16(buf []byte, n uint16) []byte { 6 wp := len(buf) 7 buf = append(buf, 0, 0) 8 binary.BigEndian.PutUint16(buf[wp:], n) 9 return buf 10 } 11 12 func AppendUint32(buf []byte, n uint32) []byte { 13 wp := len(buf) 14 buf = append(buf, 0, 0, 0, 0) 15 binary.BigEndian.PutUint32(buf[wp:], n) 16 return buf 17 } 18 19 func AppendUint64(buf []byte, n uint64) []byte { 20 wp := len(buf) 21 buf = append(buf, 0, 0, 0, 0, 0, 0, 0, 0) 22 binary.BigEndian.PutUint64(buf[wp:], n) 23 return buf 24 } 25 26 func AppendInt16(buf []byte, n int16) []byte { 27 return AppendUint16(buf, uint16(n)) 28 } 29 30 func AppendInt32(buf []byte, n int32) []byte { 31 return AppendUint32(buf, uint32(n)) 32 } 33 34 func AppendInt64(buf []byte, n int64) []byte { 35 return AppendUint64(buf, uint64(n)) 36 } 37 38 func SetInt32(buf []byte, n int32) { 39 binary.BigEndian.PutUint32(buf, uint32(n)) 40 }