From 1d751345f743461740798775ae38c98deb643398 Mon Sep 17 00:00:00 2001 From: john Date: Tue, 6 Nov 2018 12:41:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9Bgconv.Int/Uint=E5=AF=B9float?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=9A=84=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- g/util/gconv/gconv.go | 6 ++---- geg/other/test.go | 13 +++++++------ geg/other/test2.go | 8 +++----- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/g/util/gconv/gconv.go b/g/util/gconv/gconv.go index 36b0bf678..29ccfb8b8 100644 --- a/g/util/gconv/gconv.go +++ b/g/util/gconv/gconv.go @@ -123,8 +123,7 @@ func Int(i interface{}) int { } return 0 default: - v, _ := strconv.Atoi(strings.TrimSpace(String(value))) - return v + return int(Float64(value)) } } @@ -211,8 +210,7 @@ func Uint(i interface{}) uint { } return 0 default: - v, _ := strconv.ParseUint(strings.TrimSpace(String(value)), 10, 64) - return uint(v) + return uint(Float64(value)) } } diff --git a/geg/other/test.go b/geg/other/test.go index 0547cc693..a0577e76a 100644 --- a/geg/other/test.go +++ b/geg/other/test.go @@ -1,13 +1,14 @@ package main import ( - "fmt" - "strings" + "gitee.com/johng/gf/g" + "gitee.com/johng/gf/g/net/ghttp" ) func main() { - fmt.Println(strings.Trim(` 1 `, "./- \n\r")) - //fmt.Println(math.MaxInt64) - //fmt.Println(gtime.Second()) - //fmt.Println(gtime.Nanosecond()) + g.Server().BindHandler("/", func(r *ghttp.Request) { + r.Response.Write(r.GetInt("amount")) + }) + g.Server().SetPort(8199) + g.Server().Run() } \ No newline at end of file diff --git a/geg/other/test2.go b/geg/other/test2.go index 488908146..b3e410bf2 100644 --- a/geg/other/test2.go +++ b/geg/other/test2.go @@ -2,12 +2,10 @@ package main import ( "fmt" - "gitee.com/johng/gf/g/container/garray" + "gitee.com/johng/gf/g/util/gconv" ) func main() { - a := garray.NewSortedIntArray(0) - a.Add(1) - a.Remove(0) - fmt.Println(a.Len()) + fmt.Println(int(gconv.Float64("2.99s"))) + //fmt.Println(strconv.Atoi(strings.TrimSpace("1.99"))) } \ No newline at end of file