一.Json和struct互换 (1)Json转struct例子: type People struct { Name string `json:"name_title"` Age int `json:"age_size"` } func JsonToStructDemo(){ jsonStr := ` { "name_title": "jqw" "age_size":12 } ` var people P…
golang 中 map 转 struct package main import ( "fmt" "github.com/goinggo/mapstructure" ) type Person struct { Name string Age int } func MapToStruct() { mapInstance := make(map[string]interface{}) mapInstance["Name"] = "lia…
golang实验代码 package main import("fmt") type Stu struct{ name string age int } func (stu *Stu)NewAge(age int)(PriAge int){ PriAge =age stu.age = age return } func (stu Stu)NewName(name string)(PriName string){ PriName = name stu.name = name return…