Skip to content

Commit f025dc6

Browse files
committed
Fix append to slice with non-zero initial value
1 parent b5de0a9 commit f025dc6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

network/network_helpers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package network
33
import "encoding/binary"
44

55
func CreatePostgreSQLPacket(typ byte, msg []byte) []byte {
6-
packet := make([]byte, 0, 1+4+len(msg))
6+
var packet []byte
77

88
packet = append(packet, typ)
9-
binary.BigEndian.PutUint32(packet, uint32(len(msg)+4))
9+
binary.BigEndian.PutUint32(packet[1:], uint32(len(msg)+4))
1010
packet = append(packet, msg...)
1111

1212
return packet

0 commit comments

Comments
 (0)