测试用例
package code import ( "github.com/shopspring/decimal" ) //float64转成int64 func Float64ToInt64(s interface{}) int64 { var data int64 if s != nil { s1, ok := s.(float64) if ok { data = decimal.NewFromFloat(s1).IntPart() } } return data } //string转成int64 func StringToInt64(s interface{}) int64 { var data int64 if s != nil { s1, ok := s.(string) if ok { fromString, _ := decimal.NewFromString(s1) data = fromString.IntPart() } } return data }View Code