jinzhu / copier

Copier for golang, copy value from struct to struct and more
MIT License
5.58k stars 489 forks source link

0.3.4 nested struct, struct starts with lowercase, cannot copy #122

Open binbin0325 opened 2 years ago

binbin0325 commented 2 years ago

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"} )

copier.Copy(&employee, &user)

fmt.Printf("%#v \n", employee)

} `

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"}