修复gconv.Int64(float64(xxx))问题

This commit is contained in:
John
2018-05-03 18:30:16 +08:00
parent 41df1894a9
commit aed78184a6
2 changed files with 7 additions and 27 deletions

View File

@ -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

View File

@ -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)))
}