GetFloat64 same as `Get` but returns its float64 representation, if key doesn't exist then it returns -1 and a non-nil error.
(key string)
| 401 | // GetFloat64 same as `Get` but returns its float64 representation, |
| 402 | // if key doesn't exist then it returns -1 and a non-nil error. |
| 403 | func (s *Session) GetFloat64(key string) (float64, error) { |
| 404 | v := s.Get(key) |
| 405 | |
| 406 | if vfloat32, ok := v.(float32); ok { |
| 407 | return float64(vfloat32), nil |
| 408 | } |
| 409 | |
| 410 | if vfloat64, ok := v.(float64); ok { |
| 411 | return vfloat64, nil |
| 412 | } |
| 413 | |
| 414 | if vint, ok := v.(int); ok { |
| 415 | return float64(vint), nil |
| 416 | } |
| 417 | |
| 418 | if vint64, ok := v.(int64); ok { |
| 419 | return float64(vint64), nil |
| 420 | } |
| 421 | |
| 422 | if vstring, sok := v.(string); sok { |
| 423 | return strconv.ParseFloat(vstring, 32) |
| 424 | } |
| 425 | |
| 426 | return -1, newErrEntryNotFound(key, reflect.Float64, v) |
| 427 | } |
| 428 | |
| 429 | // GetFloat64Default same as `Get` but returns its float64 representation, |
| 430 | // if key doesn't exist then it returns the "defaultValue". |
no test coverage detected