aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/jackc/pgx/v5/pgproto3/big_endian.go
blob: f7bdb97eb7a30c977b4287dfa20da81ffda74386 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package pgproto3

import (
	"encoding/binary"
)

type BigEndianBuf [8]byte

func (b BigEndianBuf) Int16(n int16) []byte {
	buf := b[0:2]
	binary.BigEndian.PutUint16(buf, uint16(n))
	return buf
}

func (b BigEndianBuf) Uint16(n uint16) []byte {
	buf := b[0:2]
	binary.BigEndian.PutUint16(buf, n)
	return buf
}

func (b BigEndianBuf) Int32(n int32) []byte {
	buf := b[0:4]
	binary.BigEndian.PutUint32(buf, uint32(n))
	return buf
}

func (b BigEndianBuf) Uint32(n uint32) []byte {
	buf := b[0:4]
	binary.BigEndian.PutUint32(buf, n)
	return buf
}

func (b BigEndianBuf) Int64(n int64) []byte {
	buf := b[0:8]
	binary.BigEndian.PutUint64(buf, uint64(n))
	return buf
}