go-learning/tour_of_go/l4/maps.go

36 lines
540 B
Go
Raw Permalink Normal View History

2025-08-30 18:14:01 +00:00
package main
import "fmt"
type Vertex struct {
Lat, Long float64
}
var m map[string]Vertex
var new_m = map[string]Vertex{
"Bell Labs": Vertex{
40.68433, -74.39967,
},
"Google": Vertex{
37.42202, -122.08408,
},
}
// The above can also be written
var new_new_m = map[string]Vertex{
"Bell Labs": {40.68433, -74.39967},
"Google": {37.42202, -122.08408},
}
func main() {
m = make(map[string]Vertex)
m["Bell Labs"] = Vertex{
40.68433, -74.39967,
}
fmt.Println(m["Bell Labs"])
fmt.Println(new_m)
fmt.Println(new_new_m)
}