2019-12-02 09:57:14 -05:00
|
|
|
package main
|
|
|
|
|
2021-09-29 07:58:02 -04:00
|
|
|
import (
|
2022-03-24 08:22:05 -04:00
|
|
|
"fmt"
|
2021-09-29 07:58:02 -04:00
|
|
|
|
2022-03-24 08:22:05 -04:00
|
|
|
"github.com/jinzhu/copier"
|
2021-09-29 07:58:02 -04:00
|
|
|
)
|
2019-12-02 09:57:14 -05:00
|
|
|
|
2022-03-24 08:22:05 -04:00
|
|
|
type Cat struct {
|
|
|
|
age int
|
|
|
|
name string
|
|
|
|
friends []string
|
|
|
|
}
|
|
|
|
|
2019-12-02 09:57:14 -05:00
|
|
|
func main() {
|
2022-03-24 08:22:05 -04:00
|
|
|
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
|
|
|
}
|