MCPcopy
hub / github.com/redis/go-redis / toInt64

Function toInt64

internal/routing/aggregator.go:632–651  ·  view source on GitHub ↗
(val interface{})

Source from the content-addressed store, hash-verified

630}
631
632func toInt64(val interface{}) (int64, error) {
633 if val == nil {
634 return 0, nil
635 }
636 switch v := val.(type) {
637 case int64:
638 return v, nil
639 case int:
640 return int64(v), nil
641 case int32:
642 return int64(v), nil
643 case float64:
644 if v != math.Trunc(v) {
645 return 0, fmt.Errorf("cannot convert float %f to int64", v)
646 }
647 return int64(v), nil
648 default:
649 return 0, fmt.Errorf("cannot convert %T to int64", val)
650 }
651}
652
653func toFloat64(val interface{}) (float64, error) {
654 if val == nil {

Callers 5

BatchAddMethod · 0.70
BatchSliceMethod · 0.70
BatchAddMethod · 0.70
BatchAddMethod · 0.70
BatchSliceMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected