mirror of
https://gitee.com/johng/gf
synced 2026-06-28 18:16:26 +08:00
修复gconv.Int64(float64(xxx))问题
This commit is contained in:
@ -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
|
||||
|
||||
@ -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)))
|
||||
}
|
||||
Reference in New Issue
Block a user