gorilla/context — pull request #9 by maruel (2013-12-30 20:13:55+00:00)
Title: Enforce key type to be Key (an uintptr) and add RegisterKey() to get a fresh key

Since it is an API breaking change, I do not expect you to merge it as-is so it is more FYI.

---
The rationale is that ints are generally not useful as keys in the case of a
context that is shared across multiple unrelated packages. The different
packages must use a cooperative way of assigning globally unique keys.

Most projects will use key1 = 0, key = 1, ... but using an int via an
interface{} adds an unneeded pointer indirection to the key. Using string as
keys results in unneeded string comparison for map lookups (or worse, hashing!)
which is much less efficient than a simple embedded uintptr comparison.

The trade off is process globally unique key, faster lookup and denser map by
not using 'const' keys.

Note that this is an incompatible change, it changes the signature of the
functions.