test.go
package main import ( "fmt" ) type T struct{ name string id int info map[string]string } func (r *T)GetName() string{ fmt.Println(r.name) return r.name } func (r *T)GetId() int{ fmt.Println(r.id) return r.id } func (r *T)GetInfo(){ var v map[string]string = r.info fmt.Println(v) } func main(){ m := map[string]string{"hello":"word"} r := &T{"zhoulin",12345,m} r.GetName() r.GetId() r.GetInfo() }
test.go运行结构:
有疑问加站长微信联系(非本文作者)