Map in Go

Declare a map:

// Nil map: Read-Only
var di map[string]string


dict := map[string]string{
	"good":    "iyi",
	"great":   "harika",
	"perfect": "mükemmel",
}

Delete an element of the map using delete builtin:

delete(dict, "awesome")

Retrieve an value from map:

if value, ok := dict["great"]; ok {
    fmt.Printf("%q found in dict", value)
}

Iterate through map elements:

for key, value := range dict {
    fmt.Println(key, value)
}
go  note 

See also