To be clear, let me list the reasons why I think this is a good API addition:
1. It is consistent with the spirit of reflect.Type. There is a single reflect.Type instance returned by TypeOf for any given type. Having an ID() method for comparison or identification is consistent with that.
2. It provides very fast equality check. No matter how fast we make interface comparison (which by definition is more involved), it cannot come close to integer comparison. In a deeply recursive function where you have to check if an interface type is one of a given set everytime the function is called, integer comparison is much faster.
3. It affords very fast map access when needed. Integer map keys will always be the fastest and most performant map keys. When trying to extract performance in the fast path (e.g. encoders which run everytime data is read or written to memory or disk), this is very significant.
4. It's a 2-line addition (for gc compiler support at least). Very low cost, but very high reward.
In my codec (for binc/msgpack), I allow the user register an encoding and decoding function for any type.
Encode/Decode is a recursive function which calls itself while walking a struct, map, slice, array, etc. Each time, I look at current value and get the type. I then first check a list of builtin types in a loop to see if the type matches one of them, and if so, calls the builtin enc/dec function. If it doesn't match any of the builtin types, I then check a map for registered enc/dec functions, and if there, call the registered one. I do this each time the recursive function calls itself (e.g. walking a struct, map, slice, array). As you can imagine, the comparison checks and map access checks happening every entry into a recursive "en/decodeValue" function can get expensive. Doing integer comparisons and map access of integer keys improves performance significantly.
If JSON allows registering a function based on the type, I can see this becoming a problem that it would have to solve also.
This is not just about maps with interface keys, or interface comparison. This is about reflect.Type which is pretty fundamental (as fundamental as java.lang.Class is to java programmers).
I think this API addition is very much worth its very low cost.