Hi all,
A url.Values can write itself out in normal querystring parameter form (a=b&c=d) using
Encode(). The entire documentation for that method is:
Encode encodes the values into “URL encoded” form. e.g. "foo=bar&bar=baz"
For my application, I'm using the string representation of querystring parameters as a cache key; I need it to be stable. Now, url.Values is a map, and nothing about the ordering is mentioned in the Encode() documentation, but it so happens that the implementation of Encode() does sort the keys before writing them out:
Can I depend on this ordering to remain stable? (The answer is probably no, since it's not a documented contract.) Does it make sense to specify the ordering as part of the Encode() documentation?
One argument against it might be that leaving it unspecified leaves open the option of removing the sorting as a performance optimization.
As a side note, the example ("foo=bar&bar=baz") will actually never occur with the current implementation, since "bar" precedes "foo". (But maybe that's a subtle way of hinting that the keys will not necessarily be sorted...)
-Caleb