[Solved] Build arrays out of struct
Check it: func main() { type Something struct { Some string Thing int } var props []string var vals []string m := Something{“smth”, 123} s := reflect.ValueOf(m) for i := 0; i < s.NumField(); i++ { props = append(props, s.Type().Field(i).Name) vals = append(vals, fmt.Sprintf(“%v”, s.Field(i).Interface())) } fmt.Println(props) fmt.Println(vals) } Result: [Some Thing] [smth 123] It … Read more