diff --git a/g/util/gconv/gconv.go b/g/util/gconv/gconv.go index 45a06b7fa..041ad0992 100644 --- a/g/util/gconv/gconv.go +++ b/g/util/gconv/gconv.go @@ -86,6 +86,8 @@ func String(i interface{}) string { case uint16: return strconv.FormatUint(uint64(value), 10) case uint32: return strconv.FormatUint(uint64(value), 10) case uint64: return strconv.FormatUint(uint64(value), 10) + case float32: return strconv.FormatFloat(float64(value), 'f', -1, 64) + case float64: return strconv.FormatFloat(value, 'f', -1, 64) case bool: return strconv.FormatBool(value) case string: return value case []byte: return string(value) @@ -139,6 +141,8 @@ func Int(i interface{}) int { case uint16: return int(value) case uint32: return int(value) case uint64: return int(value) + case float32: return int(value) + case float64: return int(value) case bool: if value { return 1 @@ -205,6 +209,8 @@ func Uint(i interface{}) uint { case uint16: return uint(value) case uint32: return uint(value) case uint64: return uint(value) + case float32: return uint(value) + case float64: return uint(value) case bool: if value { return 1 diff --git a/geg/other/test.go b/geg/other/test.go index 24a51ddb9..b7975600a 100644 --- a/geg/other/test.go +++ b/geg/other/test.go @@ -1,35 +1,9 @@ package main import ( - "runtime" - "strconv" "fmt" - "gitee.com/johng/gf/g/util/gregx" - "gitee.com/johng/gf/g/os/gfile" ) -func Test() { - backtrace := "Trace:\n" - index := 0 - for i := 1; i < 10000; i++ { - if _, cfile, cline, ok := runtime.Caller(i); ok { - // 不打印出go源码路径 - if !gregx.IsMatchString("^" + runtime.GOROOT(), cfile) { - fmt.Println(gfile.Dir(cfile)) - backtrace += strconv.Itoa(index) + ". " + cfile + ":" + strconv.Itoa(cline) + "\n" - index++ - } - } else { - break - } - } - fmt.Println(backtrace) -} - -func Test2() { - Test() -} - func main() { - Test2() + fmt.Println(int(float64(149860800000))) } \ No newline at end of file