Skip to content

Instantly share code, notes, and snippets.

@ijonas
Created September 15, 2013 07:56
Show Gist options
  • Save ijonas/6568774 to your computer and use it in GitHub Desktop.
Save ijonas/6568774 to your computer and use it in GitHub Desktop.
In Go: a Map of Structs returns copies of the original struct stored in the map
package main
import "fmt"
type Person struct {
Name string
}
func main() {
myhash := make(map[string]Person)
myhash["ijonas"] = Person{"Ijonas Kisselbach"}
ik1 := myhash["ijonas"]
fmt.Printf("%p\n", &ik1) // e.g. 0xc010035160
ik2 := myhash["ijonas"]
fmt.Printf("%p\n", &ik2) // e.g. 0xc010035190
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment