diff --git a/geg/util/gconv/gconv.go b/geg/util/gconv/gconv.go index 1c7a765b0..eb04af931 100644 --- a/geg/util/gconv/gconv.go +++ b/geg/util/gconv/gconv.go @@ -6,7 +6,7 @@ import ( ) func main() { - i := 123 + i := 123.456 fmt.Printf("%10s %v\n", "Int:", gconv.Int(i)) fmt.Printf("%10s %v\n", "Int8:", gconv.Int8(i)) fmt.Printf("%10s %v\n", "Int16:", gconv.Int16(i)) diff --git a/geg/util/gconv/gconv_struct4.go b/geg/util/gconv/gconv_struct4.go index 797ce13db..4a69f3015 100644 --- a/geg/util/gconv/gconv_struct4.go +++ b/geg/util/gconv/gconv_struct4.go @@ -11,11 +11,15 @@ func main() { Name string Result int } - type User struct { + type User1 struct { Scores Score } + type User2 struct { + Scores *Score + } - user := new(User) + user1 := new(User1) + user2 := new(User2) scores := map[string]interface{}{ "Scores" : map[string]interface{}{ "Name" : "john", @@ -23,10 +27,14 @@ func main() { }, } - // 嵌套struct转换 - if err := gconv.Struct(scores, user); err != nil { + if err := gconv.Struct(scores, user1); err != nil { fmt.Println(err) } else { - g.Dump(user) + g.Dump(user1) + } + if err := gconv.Struct(scores, user2); err != nil { + fmt.Println(err) + } else { + g.Dump(user2) } } \ No newline at end of file