- Published on
How to convert Golang pgtype.UUID to string
- Authors
- Name
- Geonhyuk Im
- @GeonHyuk
func UUIDToString(t pgtype.UUID) string {
if !t.Valid {
return ""
}
src := t.Bytes
return fmt.Sprintf("%x-%x-%x-%x-%x", src[0:4], src[4:6], src[6:8], src[8:10], src[10:16])
}