Created
September 15, 2013 07:56
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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