After renaming a type, I cannot access some of its methods

让人想犯罪 __ 提交于 2019-12-05 21:00:43

you should use struct embedding rather than type define. check the struct 'embedding' document:

but then to promote the methods of the fields and to satisfy the io interfaces, we would also need to provide forwarding methods, like this:

func (rw *ReadWriter) Read(p []byte) (n int, err error) { return rw.reader.Read(p) }

By embedding the structs directly, we avoid this bookkeeping.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!