gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

big_endian.go (663B)


      1 package pgproto3
      2 
      3 import (
      4 	"encoding/binary"
      5 )
      6 
      7 type BigEndianBuf [8]byte
      8 
      9 func (b BigEndianBuf) Int16(n int16) []byte {
     10 	buf := b[0:2]
     11 	binary.BigEndian.PutUint16(buf, uint16(n))
     12 	return buf
     13 }
     14 
     15 func (b BigEndianBuf) Uint16(n uint16) []byte {
     16 	buf := b[0:2]
     17 	binary.BigEndian.PutUint16(buf, n)
     18 	return buf
     19 }
     20 
     21 func (b BigEndianBuf) Int32(n int32) []byte {
     22 	buf := b[0:4]
     23 	binary.BigEndian.PutUint32(buf, uint32(n))
     24 	return buf
     25 }
     26 
     27 func (b BigEndianBuf) Uint32(n uint32) []byte {
     28 	buf := b[0:4]
     29 	binary.BigEndian.PutUint32(buf, n)
     30 	return buf
     31 }
     32 
     33 func (b BigEndianBuf) Int64(n int64) []byte {
     34 	buf := b[0:8]
     35 	binary.BigEndian.PutUint64(buf, uint64(n))
     36 	return buf
     37 }