mirror of
https://gitee.com/johng/gf.git
synced 2024-12-03 20:58:47 +08:00
30 lines
388 B
Go
30 lines
388 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gogf/gf/util/gconv"
|
|
)
|
|
|
|
func main() {
|
|
type User struct {
|
|
Uid int `json:"uid"`
|
|
Name string `json:"name"`
|
|
}
|
|
// 对象
|
|
fmt.Println(gconv.Map(User{
|
|
Uid: 1,
|
|
Name: "john",
|
|
}))
|
|
// 对象指针
|
|
fmt.Println(gconv.Map(&User{
|
|
Uid: 1,
|
|
Name: "john",
|
|
}))
|
|
|
|
// 任意map类型
|
|
fmt.Println(gconv.Map(map[int]int{
|
|
100: 10000,
|
|
}))
|
|
}
|