How does embedding without some specific methods work?

65 views
Skip to first unread message

William Tang

unread,
Jul 12, 2024, 9:13:03 AM (4 days ago) Jul 12
to golang-nuts
I’m reading the current implementation of io.Copy for TCPConn. It has a struct called tcpConnWithoutWriteTo 3, which will cause the WriterTo casting from a io.Reader to fail 1. How and why does it work internally?

Ian Lance Taylor

unread,
Jul 12, 2024, 9:20:13 AM (4 days ago) Jul 12
to William Tang, golang-nuts
On Fri, Jul 12, 2024 at 6:12 AM William Tang <galaxyk...@gmail.com> wrote:
>
> I’m reading the current implementation of io.Copy for TCPConn. It has a struct called tcpConnWithoutWriteTo 3, which will cause the WriterTo casting from a io.Reader to fail 1. How and why does it work internally?

When there are two promoted methods with the same name, both methods
are ignored. The language spec lists the rules at
https://go.dev/ref/spec#Selectors.

Ian
Reply all
Reply to author
Forward
0 new messages