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

Method Scan

example/sql_enum.go:99–180  ·  view source on GitHub ↗

one per type for package clashes Scan implements the Scanner interface.

(value interface{})

Source from the content-addressed store, hash-verified

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

Callers 4

NewNullProjectStatusFunction · 0.45
ScanMethod · 0.45
NewNullProjectStatusStrFunction · 0.45
UnmarshalJSONMethod · 0.45

Calls 2

ProjectStatusTypeAlias · 0.85
ParseProjectStatusFunction · 0.85

Tested by

no test coverage detected