Skip to content

Instantly share code, notes, and snippets.

@dmichael
Last active May 25, 2017 17:47
Show Gist options
  • Save dmichael/5622511 to your computer and use it in GitHub Desktop.
Save dmichael/5622511 to your computer and use it in GitHub Desktop.
Struct copy/clone
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)
}
@dmichael
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment