I know the value is not same so I double qouted it, what I want to know is how go's map hash works so that cusKey and a is different in type result in the key is different.
package main
import (
"fmt"
)
type key int
const cusKey key = 1
const a int = 1
func main() {
dic := make(map[interface{}]interface{})
dic[cusKey] = 5
dic[a] = 6
fmt.Println(dic[cusKey])
fmt.Println(dic[a])
}
the output is
5
6
How go achieve this? The two keys value are all 1.
I know in go if the type is different, two value is different. So the two 1 is not identical.
But how actually go's map did it? I tried to find out at map.go in source, but I can't found where go implement the hash funcion. Is it calculates hash of the keys with type annotations?