Open binbin0325 opened 2 years ago
code `package main
import ( "fmt" "github.com/jinzhu/copier" )
type baseUser struct { Id int Name string }
type User struct { baseUser Name string }
type Employee struct { baseUser // Tell copier.Copy to panic if this field is not copied. Name string copier:"must" }
copier:"must"
func main() { b := baseUser{Id: 11} var ( user = User{baseUser: b, Name: "Jinzhu"} employee = Employee{Name: "zzz"} )
copier.Copy(&employee, &user) fmt.Printf("%#v \n", employee)
} `
0.3.4 nested struct, struct starts with lowercase, cannot copy
version:0.3.4 output: main.Employee{baseUser:main.baseUser{Id:0, Name:""}, Name:"Jinzhu"}
output: main.Employee{baseUser:main.baseUser{Id:0, Name:""}, Name:"Jinzhu"}
version:0.3.2 output: main.Employee{baseUser:main.baseUser{Id:11, Name:""}, Name:"Jinzhu"}
output: main.Employee{baseUser:main.baseUser{Id:11, Name:""}, Name:"Jinzhu"}
Reproducible Example
code `package main
import ( "fmt" "github.com/jinzhu/copier" )
type baseUser struct { Id int Name string }
type User struct { baseUser Name string }
type Employee struct { baseUser // Tell copier.Copy to panic if this field is not copied. Name string
copier:"must"
}func main() { b := baseUser{Id: 11} var ( user = User{baseUser: b, Name: "Jinzhu"} employee = Employee{Name: "zzz"} )
} `
Description
0.3.4 nested struct, struct starts with lowercase, cannot copy
version:0.3.4
output: main.Employee{baseUser:main.baseUser{Id:0, Name:""}, Name:"Jinzhu"}
version:0.3.2
output: main.Employee{baseUser:main.baseUser{Id:11, Name:""}, Name:"Jinzhu"}