1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-02 02:30:19 +00:00
Files
Beego/pagination/utils.go
2014-10-02 11:40:46 +02:00

21 lines
400 B
Go

package pagination
import (
"fmt"
"reflect"
)
// convert any numeric value to int64
func ToInt64(value interface{}) (d int64, err error) {
val := reflect.ValueOf(value)
switch value.(type) {
case int, int8, int16, int32, int64:
d = val.Int()
case uint, uint8, uint16, uint32, uint64:
d = int64(val.Uint())
default:
err = fmt.Errorf("ToInt64 need numeric not `%T`", value)
}
return
}