We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
如何Copy非匿名嵌套结构体
type A struct { Address string } type Project struct { Name string } type AWithProject struct { A A Project Project } type C struct{ Address string Project struct{ Name string } } // 以上的情况从AWithProject 到 C只能成功复制Project的内容,无法复制Address这个字段,尝试过添加tag也无法生效
The text was updated successfully, but these errors were encountered:
在C中使用匿名嵌套A的方式可以解决以上问题,貌似也属于是曲线救国了,要是库能原生支持就好了,或者使用tag支持xx.xx的嵌套层级,这样可以更方便的实现一些功能
Sorry, something went wrong.
不是有一种Method到Field的写法吗? 我觉得你可以添加一个Address方法就可以实现了。
func (a * AWithProject) Address() string { return a.A.Address }
jinzhu
No branches or pull requests
如何Copy非匿名嵌套结构体
The text was updated successfully, but these errors were encountered: