GetUint64 same as `Get` but returns as uint64, if key doesn't exist then it returns 0 and a non-nil error.
(key string)
| 319 | // GetUint64 same as `Get` but returns as uint64, |
| 320 | // if key doesn't exist then it returns 0 and a non-nil error. |
| 321 | func (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". |
no test coverage detected