Add function asIntFromTimeDuration()

pull/642/head
Elias Rodrigues 4 years ago
parent 1c4e56307b
commit 94470e68f3
  1. 10
      util.go

@ -4,6 +4,7 @@ import (
"reflect" "reflect"
"strconv" "strconv"
"strings" "strings"
"time"
) )
// extractTypeInternal gets the actual underlying type of field value. // extractTypeInternal gets the actual underlying type of field value.
@ -229,6 +230,15 @@ func asInt(param string) int64 {
return i return i
} }
// asIntFromTimeDuration parses param as time.Duration and returns it as int64
// or panics on error.
func asIntFromTimeDuration(param string) int64 {
d, err := time.ParseDuration(param)
panicIf(err)
return int64(d)
}
// asUint returns the parameter as a uint64 // asUint returns the parameter as a uint64
// or panics if it can't convert // or panics if it can't convert
func asUint(param string) uint64 { func asUint(param string) uint64 {

Loading…
Cancel
Save