-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
What version of Go are you using (go version)?
master
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
N/A
What did you do?
I was leveraging a go library for restful api communication, and ran into a frustrating issue where the url parameters were being sorted alphabetically. Normally, this does not matter. However, with the advent of HMAC Signing and many APIs using it now, this becomes a problem. The idea is that you sign the url which in a GET situation includes the url parameters and append a new hmac_sign parameter to the end. This works fine in many languages except Go.
I don't know for sure why the go team decided to do this. I suspect that the decision was made to use map[string]string to hold the url parameters. Since maps do not guarantee an order, a sort was done to make the return deterministic.
I would like to suggest this be backed by an array so it can be possible to preserve an order to support the above mentioned use case. This allows libraries to also support ordering while still depending on the core Go libraries.
What did you expect to see?
I expect that as I set parameters the order is maintained when I call the encode function.
What did you see instead?
Instead they are sorted alphabetically.