// Scan implements sql.Scanner so UUIDs can be read from databases transparently // Currently, database types that map to string and []byte are supported. Please // consult database-specific driver documentation for matching types. func (u *UUID) Scan(src interface{}) error { var id uuid.UUID if err := id.Scan(src); err != nil { return err } // Only update u if we recevied a non-nil uuid if id != uuid.NIL { *u = id[:] } return nil }
// UnmarshalText implements encoding.TextUnmarshaler. func (u *UUID) UnmarshalText(data []byte) error { if len(data) == 0 { return nil } var id uuid.UUID if err := id.UnmarshalText(data); err != nil { return err } *u = id[:] return nil }