如何在PostForm中遍历数组值?

I've been trying to read the values contained in an array sent by a Post Submit in a website.

Printing the r.PostForm data returns this map:

map[myArray[0].val1:[foo1] myArray[0].val2:[foo2] myArray[1].val1:[foo1] myArray[1].val2:[foo2]]

How can we manipulate the data? I already tried something like this:

func request(r http.ResponseWriter, w *http.Request){
    r.ParseForm()
    for key, array := range r.PostForm["myArray"] {
        // Do something with the val1 and val2 values.
    }
}

But this didn't work and I hadn't found any solution in the web.

Is possible to read an array contained in Post data using a basic solution?

It looks like the keys of your form are "myArray[0].val1", "myArray[0].val2", and so on.

Try:

r.ParseForm()
for k, v := range r.PostForm {
    for i, value := range v {
        // Do something with the i-th value for key k.
    }
}