Map

  • Map
// map[key-type]value-type  
messages := make(map[string]string)
 
// Literal
var m = map[string]Vertex{
	"Bell Labs": Vertex{
		40.68433, -74.39967,
	},
	"Google": Vertex{
		37.42202, -122.08408,
	},
}
 
// insert or update
m[key] = elem
  • Delete an element:
    delete(m, key)

  • Test that a key is present with a two-value assignment:
    elem, ok = m[key]