Last active
May 25, 2017 17:47
-
-
Save dmichael/5622511 to your computer and use it in GitHub Desktop.
Struct copy/clone
This file contains 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 Cat struct { | |
name string | |
skill string | |
} | |
func main() { | |
cat1 := &Cat{name: "Toonces", skill: "driving"} | |
cat2 := *cat1 | |
cat2.name = "Felix" | |
fmt.Println(cat1.name, "is good at", cat1.skill) | |
fmt.Println(cat2.name, "is good at", cat2.skill) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://play.golang.org/p/-1fwEqjeJA