package reflection import ( "fmt" "testing" ) type Fakeb struct { In int `json:"in"` } type fake struct { Name string `json:"name"` Age int `json:"age"` Usage *Fakeb `json:"usage"` } func TestSetter(t *testing.T) { dst := &fake{} ms := map[string]any{"name": "aa", "age": "5", "usage": map[string]any{"in": 15}} err := Setter(dst, ms) if err != nil { t.Error(err) return } if dst.Age != 5 { t.Errorf("setter failed") } else { fmt.Println(dst.Usage.In) fmt.Printf("%+v", dst) } }