Open w22296437978 opened 1 year ago
type Dto struct { Name string } func main() { list1 := []Dto{{"你好"}} list2 := []Dto{} copier.Copy(&list2, &list1) fmt.Printf("list2 length = %d\r\n", len(list2)) // 1 list2 = []Dto{} list1Interface := method(list1) copier.Copy(&list2, &list1Interface) fmt.Printf("list2 length = %d\n", len(list2)) // 0 ??? list2 = []Dto{} list1Interface = method(list1) copier.Copy(&list2, list1Interface) fmt.Printf("list2 length = %d\n", len(list2)) // 1 ??? } func method(a interface{}) interface{} { return a }