Skip to content

Instantly share code, notes, and snippets.

@kamatama41
Last active August 29, 2015 14:05
Show Gist options
  • Save kamatama41/b1ec3e6aaaa9ee878cb4 to your computer and use it in GitHub Desktop.
Save kamatama41/b1ec3e6aaaa9ee878cb4 to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Key struct {
Name string
}
type Vertex struct {
Lat, Long float64
}
var m map[Key]Vertex
func main() {
m = make(map[Key]Vertex)
m[Key{"Bell Labs"}] = Vertex{
40.68433, -74.39967,
}
val := m[Key{"Bell Labs"}]
fmt.Println(val)
// 取り出した変数を変更してもMapの中身に影響は無い
val.Lat = 1.234
val2 := m[Key{"Bell Labs"}]
fmt.Println(val2)
}
// result
//{40.68433 -74.39967}
//{40.68433 -74.39967}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment