...
1 package pq
2
3 import (
4 "encoding/hex"
5 "fmt"
6 )
7
8
9 func decodeUUIDBinary(src []byte) ([]byte, error) {
10 if len(src) != 16 {
11 return nil, fmt.Errorf("pq: unable to decode uuid; bad length: %d", len(src))
12 }
13
14 dst := make([]byte, 36)
15 dst[8], dst[13], dst[18], dst[23] = '-', '-', '-', '-'
16 hex.Encode(dst[0:], src[0:4])
17 hex.Encode(dst[9:], src[4:6])
18 hex.Encode(dst[14:], src[6:8])
19 hex.Encode(dst[19:], src[8:10])
20 hex.Encode(dst[24:], src[10:16])
21
22 return dst, nil
23 }
24
View as plain text