Last change
on this file since 822 was 822, checked in by yakumo.izuru, 22 months ago |
Prefer immortal.run over runit and rc.d, use vendored modules
for convenience.
Signed-off-by: Izuru Yakumo <yakumo.izuru@…>
|
File size:
555 bytes
|
Line | |
---|
1 | package pq
|
---|
2 |
|
---|
3 | import (
|
---|
4 | "encoding/hex"
|
---|
5 | "fmt"
|
---|
6 | )
|
---|
7 |
|
---|
8 | // decodeUUIDBinary interprets the binary format of a uuid, returning it in text format.
|
---|
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 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.