I tried to comment on the site, but it’s held up in the moderation queue ATM.
type B A defines B as having the data of A, but not the methods. type B struct { A } will inherit the methods of A, and type B = A is just an alias for A, not a new type. So, type fishTank container[fish] should be type fishTank struct { container[fish] } since he wants to add a new method but inherit the old ones.
The thing about comparable is a sprawling debate in the Go Github issues. Long story short, you can use an interface value as a map key in normal Go, but it will blow up if the concrete value behind the interface is incomparable. It is however forbidden in generic Go. Language developers are having a long debate about how to make this work consistently.
I tried to comment on the site, but it’s held up in the moderation queue ATM.
type B A
defines B as having the data of A, but not the methods.type B struct { A }
will inherit the methods of A, andtype B = A
is just an alias for A, not a new type. So,type fishTank container[fish]
should betype fishTank struct { container[fish] }
since he wants to add a new method but inherit the old ones.The thing about
comparable
is a sprawling debate in the Go Github issues. Long story short, you can use an interface value as a map key in normal Go, but it will blow up if the concrete value behind the interface is incomparable. It is however forbidden in generic Go. Language developers are having a long debate about how to make this work consistently.