MCPcopy
hub / github.com/cortexlabs/cortex / InterfaceToInt64

Function InterfaceToInt64

pkg/lib/cast/interface.go:264–283  ·  view source on GitHub ↗
(in interface{})

Source from the content-addressed store, hash-verified

262}
263
264func InterfaceToInt64(in interface{}) (int64, bool) {
265 var ok bool
266 if in, ok = JSONNumberToInt(in); !ok {
267 return 0, false
268 }
269
270 switch casted := in.(type) {
271 case int8:
272 return int64(casted), true
273 case int16:
274 return int64(casted), true
275 case int32:
276 return int64(casted), true
277 case int:
278 return int64(casted), true
279 case int64:
280 return casted, true
281 }
282 return 0, false
283}
284
285func InterfaceToInt64Downcast(in interface{}) (int64, bool) {
286 var ok bool

Callers 6

StrIfPluralFunction · 0.92
PluralCustomFunction · 0.92
Int64Function · 0.92
Int64ListFunction · 0.92
Int64PtrFunction · 0.92
InterfaceToInt64SliceFunction · 0.85

Calls 1

JSONNumberToIntFunction · 0.85

Tested by

no test coverage detected