MCPcopy Create free account
hub / github.com/abice/go-enum / Scan

Method Scan

example/sql_str_int_enum.go:101–171  ·  view source on GitHub ↗

Scan implements the Scanner interface.

(value interface{})

Source from the content-addressed store, hash-verified

99
100// Scan implements the Scanner interface.
101func (x *GreekGod) Scan(value interface{}) (err error) {
102 if value == nil {
103 *x = GreekGod("")
104 return
105 }
106
107 // A wider range of scannable types.
108 // driver.Value values at the top of the list for expediency
109 switch v := value.(type) {
110 case int64:
111 *x, err = lookupSqlIntGreekGod(v)
112 case string:
113 *x, err = ParseGreekGod(v)
114 case []byte:
115 if val, verr := strconv.ParseInt(string(v), 10, 64); verr == nil {
116 *x, err = lookupSqlIntGreekGod(val)
117 } else {
118 // try parsing the value as a string
119 *x, err = ParseGreekGod(string(v))
120 }
121 case GreekGod:
122 *x = v
123 case int:
124 *x, err = lookupSqlIntGreekGod(int64(v))
125 case *GreekGod:
126 if v == nil {
127 return errGreekGodNilPtr
128 }
129 *x = *v
130 case uint:
131 *x, err = lookupSqlIntGreekGod(int64(v))
132 case uint64:
133 *x, err = lookupSqlIntGreekGod(int64(v))
134 case *int:
135 if v == nil {
136 return errGreekGodNilPtr
137 }
138 *x, err = lookupSqlIntGreekGod(int64(*v))
139 case *int64:
140 if v == nil {
141 return errGreekGodNilPtr
142 }
143 *x, err = lookupSqlIntGreekGod(int64(*v))
144 case float64: // json marshals everything as a float64 if it's a number
145 *x, err = lookupSqlIntGreekGod(int64(v))
146 case *float64: // json marshals everything as a float64 if it's a number
147 if v == nil {
148 return errGreekGodNilPtr
149 }
150 *x, err = lookupSqlIntGreekGod(int64(*v))
151 case *uint:
152 if v == nil {
153 return errGreekGodNilPtr
154 }
155 *x, err = lookupSqlIntGreekGod(int64(*v))
156 case *uint64:
157 if v == nil {
158 return errGreekGodNilPtr

Callers 4

NewNullGreekGodFunction · 0.45
ScanMethod · 0.45
NewNullGreekGodCustomFunction · 0.45
ScanMethod · 0.45

Calls 3

GreekGodTypeAlias · 0.85
lookupSqlIntGreekGodFunction · 0.85
ParseGreekGodFunction · 0.85

Tested by

no test coverage detected