MCPcopy Create free account
hub / github.com/kataras/iris / GetUint64

Method GetUint64

sessions/session.go:321–347  ·  view source on GitHub ↗

GetUint64 same as `Get` but returns as uint64, if key doesn't exist then it returns 0 and a non-nil error.

(key string)

Source from the content-addressed store, hash-verified

319// GetUint64 same as `Get` but returns as uint64,
320// if key doesn't exist then it returns 0 and a non-nil error.
321func (s *Session) GetUint64(key string) (uint64, error) {
322 v := s.Get(key)
323 if v != nil {
324 switch vv := v.(type) {
325 case string:
326 val, err := strconv.ParseUint(vv, 10, 64)
327 if err != nil {
328 return 0, err
329 }
330 return uint64(val), nil
331 case uint8:
332 return uint64(vv), nil
333 case uint16:
334 return uint64(vv), nil
335 case uint32:
336 return uint64(vv), nil
337 case uint64:
338 return vv, nil
339 case int64:
340 return uint64(vv), nil
341 case int:
342 return uint64(vv), nil
343 }
344 }
345
346 return 0, newErrEntryNotFound(key, reflect.Uint64, v)
347}
348
349// GetUint64Default same as `Get` but returns as uint64,
350// if key doesn't exist it returns the "defaultValue".

Callers 3

GetUint64DefaultMethod · 0.95
newAppFunction · 0.45
mainFunction · 0.45

Calls 2

GetMethod · 0.95
newErrEntryNotFoundFunction · 0.85

Tested by

no test coverage detected