Type system

Go map types

Associates comparable keys with values. Missing keys yield the value type zero value; use comma-ok to distinguish absence. Iteration order is unspecified. Example output: '0 true false'.

Formal Syntax & Structure

go syntaxgo
map[K]V

Working Example

Example Snippetgo
package main
import (  "fmt")
func main() {  m := map[string]int{"a": 0}  v, ok := m["a"]  _, missing := m["b"]  fmt.Println(v, ok, missing)}
Go Reference