MCPcopy Create free account
hub / github.com/PostHog/duckgres / decodeUUID

Function decodeUUID

server/types.go:556–562  ·  view source on GitHub ↗

decodeUUID decodes 16 raw bytes into a UUID string "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".

(data []byte)

Source from the content-addressed store, hash-verified

554
555// decodeUUID decodes 16 raw bytes into a UUID string "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".
556func decodeUUID(data []byte) (string, error) {
557 if len(data) != 16 {
558 return "", fmt.Errorf("invalid UUID binary data: got %d bytes, need 16", len(data))
559 }
560 s := hex.EncodeToString(data)
561 return s[0:8] + "-" + s[8:12] + "-" + s[12:16] + "-" + s[16:20] + "-" + s[20:32], nil
562}
563
564// encodeTime encodes a TIME value as int64 microseconds since midnight (PostgreSQL binary format).
565// DuckDB Go driver returns TIME as time.Time with date fixed to 0001-01-01.

Callers 3

TestEncodeDecodeUUIDFunction · 0.85
decodeBinaryCopyFunction · 0.85
decodeBinaryFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestEncodeDecodeUUIDFunction · 0.68