-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Milestone
Description
Right now, if one wants to decode an URL query string into an existing non-nil Values map, the only way is something like:
values2, err := url.ParseQuery(query)
if err != nil {
...
}
for key, value := range values2 {
values[key] = append(values[key], value...)
}
This means an extra allocation, and the piece of boilerplate seems like it should be unnecessary.
I think this would be much nicer, to mirror the Encode() string method we already have:
if err := values.Decode(query); err != nil {
...
}
The implementation would be trivial. We already have a parseQuery(m Values, query string) (err error) function, so it could be moved to the method, and ParseQuery could use the method directly.
jimmyfrasche, rogpeppe, aofei, thesyncim and nightlyoneicholy