-
Notifications
You must be signed in to change notification settings - Fork 2
/
empty.go
50 lines (39 loc) · 860 Bytes
/
empty.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
package pgproto
import (
"fmt"
"io"
)
type EmptyQueryResponse struct{}
func (e *EmptyQueryResponse) server() {}
func ParseEmptyQueryResponse(r io.Reader) (*EmptyQueryResponse, error) {
b := newReadBuffer(r)
// 'I' [int32 - length]
err := b.ReadTag('I')
if err != nil {
return nil, err
}
l, err := b.ReadInt()
if err != nil {
return nil, err
}
if l != 4 {
return nil, fmt.Errorf("expected message length of 4")
}
return &EmptyQueryResponse{}, nil
}
func (e *EmptyQueryResponse) Encode() []byte {
// 'I' [int32 - length]
return []byte{
// Tag
'I',
// Length
'\x00', '\x00', '\x00', '\x04',
}
}
func (e *EmptyQueryResponse) AsMap() map[string]interface{} {
return map[string]interface{}{
"Type": "EmptyQueryResponse",
"Payload": nil,
}
}
func (e *EmptyQueryResponse) String() string { return messageToString(e) }