Please help to find the list of builtin map type method. Sources are OK. I see Add
and Set
in different examples and I would like to know the difference.
The following was found but gives no help:
https://golang.org/src/runtime/hashmap.go - implementation, but where is the interface? https://blog.golang.org/go-maps-in-action - an article on maps, but can't find the complete method list.
Map types in Go do not implement any interfaces (except the empty interface interface{}
) because map types have no methods.
To verify:
fmt.Println(reflect.TypeOf(map[int]int{}).NumMethod())
Which prints (try it on the Go Playground):
0
Setting / getting / removing elements from a map is covered by the language spec (e.g. Index expressions). Also the number of entries in a map is a builtin function: len()
.