github.com/zhongdalu/gf@v1.0.0/geg/util/gconv/gconv_map_deep.go (about)

     1  package main
     2  
     3  import (
     4  	"github.com/zhongdalu/gf/g"
     5  	"github.com/zhongdalu/gf/g/util/gconv"
     6  )
     7  
     8  func main() {
     9  	type Ids struct {
    10  		Id  int `json:"id"`
    11  		Uid int `json:"uid"`
    12  	}
    13  	type Base struct {
    14  		Ids
    15  		CreateTime string `json:"create_time"`
    16  	}
    17  	type User struct {
    18  		Base
    19  		Passport string `json:"passport"`
    20  		Password string `json:"password"`
    21  		Nickname string `json:"nickname"`
    22  	}
    23  	user := new(User)
    24  	user.Id = 1
    25  	user.Uid = 100
    26  	user.Nickname = "John"
    27  	user.Passport = "johng"
    28  	user.Password = "123456"
    29  	user.CreateTime = "2019"
    30  	g.Dump(gconv.MapDeep(user))
    31  }