nezha/cmd/playground/main.go

28 lines
510 B
Go
Raw Normal View History

2019-12-02 09:57:14 -05:00
package main
import (
"fmt"
"github.com/jinzhu/copier"
)
2019-12-02 09:57:14 -05:00
type Cat struct {
age int
name string
friends []string
}
2019-12-02 09:57:14 -05:00
func main() {
a := Cat{7, "Wilson", []string{"Tom", "Tabata", "Willie"}}
b := Cat{7, "Wilson", []string{"Tom", "Tabata", "Willie"}}
c := Cat{7, "Wilson", []string{"Tom", "Tabata", "Willie"}}
wilson := []*Cat{&a, &b, &c}
nikita := []Cat{}
copier.Copy(&nikita, &wilson)
nikita[0].friends = append(nikita[0].friends, "Syd")
fmt.Println(wilson[0])
fmt.Println(nikita[0])
2019-12-02 09:57:14 -05:00
}