I need to be able to to something like this in my HTML forms:
<form method="POST">
<input type="text" name="cart[items][1][qty]" value="3"/>
<input type="text" name="cart[items][2][qty]" value="7"/>
<input type="submit" value="Update cart"/>
</form>
Problem is, if I print out r.Form
(after r.ParseForm() of course!), it is revealed that Go parses it as separate strings - not the nested hierarchy I'm after.
I was able to find an alternative in http://www.gorillatoolkit.org/pkg/schema , however I'd be very interested in finding out if there's a native/vanilla solution, since I usually tend to try an limit external packages, if I don't need them.
To be more specific, in the above example I'd expect to get the entire nested slice/map, when I do r.Form["cart"]
, but that's obviously not how it works. The value I get is [].
Is using schema the best solution for this, or is it possible to achieve exactly what I'm after? If then, how would you do it? :-)