gf/.example/util/gconv/gconv_struct_create.go

24 lines
310 B
Go

package main
import (
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv"
)
func main() {
type User struct {
Uid int
Name string
}
user := (*User)(nil)
params := g.Map{
"uid": 1,
"name": "john",
}
err := gconv.Struct(params, &user)
if err != nil {
panic(err)
}
g.Dump(user)
}