MCPcopy Create free account
hub / github.com/lib/pq / decodeUUIDBinary

Function decodeUUIDBinary

encode.go:84–97  ·  view source on GitHub ↗

decodeUUIDBinary interprets the binary format of a uuid, returning it in text format.

(src []byte)

Source from the content-addressed store, hash-verified

82
83// decodeUUIDBinary interprets the binary format of a uuid, returning it in text format.
84func decodeUUIDBinary(src []byte) ([]byte, error) {
85 if len(src) != 16 {
86 return nil, fmt.Errorf("pq: unable to decode uuid; bad length: %d", len(src))
87 }
88
89 dst := make([]byte, 36)
90 dst[8], dst[13], dst[18], dst[23] = '-', '-', '-', '-'
91 hex.Encode(dst[0:], src[0:4])
92 hex.Encode(dst[9:], src[4:6])
93 hex.Encode(dst[14:], src[6:8])
94 hex.Encode(dst[19:], src[8:10])
95 hex.Encode(dst[24:], src[10:16])
96 return dst, nil
97}
98
99func textDecode(ps *parameterStatus, s []byte, typ oid.Oid) (any, error) {
100 switch typ {

Callers 2

BenchmarkDecodeFunction · 0.85
binaryDecodeFunction · 0.85

Calls

no outgoing calls

Tested by 1

BenchmarkDecodeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…