The keys on the form look like rating[id]where idis the value identifier. To get one of the values, call r.FormValue("rating[id]")after substitution idfor the actual value of id.
I suggest that you print the form to find out what happens:
fmt.Printf("%+v\n", r.Form) // No () following Form, Form is not a function
form is url.Values , Url.Values - a string [string] []. You can iterate through the form as follows:
for key, values := range r.Form { // range over map
for _, value := range values { // range over []string
fmt.Println(key, value)
}
}
source
share