MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / Scan

Method Scan

pkg/util/uuid/sql.go:29–46  ·  view source on GitHub ↗

Scan implements the sql.Scanner interface. A 16-byte slice will be handled by UnmarshalBinary, while a longer byte slice or a string will be handled by UnmarshalText.

(src interface{})

Source from the content-addressed store, hash-verified

27// A 16-byte slice will be handled by UnmarshalBinary, while
28// a longer byte slice or a string will be handled by UnmarshalText.
29func (u *UUID) Scan(src interface{}) error {
30 switch src := src.(type) {
31 case UUID: // support gorm convert from UUID to NullUUID
32 *u = src
33 return nil
34
35 case []byte:
36 if len(src) == Size {
37 return u.UnmarshalBinary(src)
38 }
39 return u.UnmarshalText(src)
40
41 case string:
42 return u.UnmarshalText([]byte(src))
43 }
44
45 return fmt.Errorf("uuid: cannot convert %T to UUID", src)
46}
47
48// NullUUID can be used with the standard sql package to represent a
49// UUID value that can be NULL in the database.

Callers 3

ScanMethod · 0.45
scanMethod · 0.45
generateSnapshotMethod · 0.45

Calls 3

UnmarshalBinaryMethod · 0.95
UnmarshalTextMethod · 0.95
ErrorfMethod · 0.80

Tested by

no test coverage detected