Map literals

Map literals are like struct literals, but the keys are required.

map-literals.go

  1. package main
  2. import "fmt"
  3. type Vertex struct {
  4. Lat, Long float64
  5. }
  6. var m = map[string]Vertex{
  7. "Bell Labs": Vertex{
  8. 40.68433, -74.39967,
  9. },
  10. "Google": Vertex{
  11. 37.42202, -122.08408,
  12. },
  13. }
  14. func main() {
  15. fmt.Println(m)
  16. }