This is the book I used to learn Go after the Tour of Go. It has the 
benefit of teaching you both Test-Driven Development and the Go programming 
language.

https://quii.gitbook.io/learn-go-with-tests

On Saturday, November 15, 2025 at 7:15:43 AM UTC-5 alex-coder wrote:

> Hi Jason.
>
> Yes, you are right. In context of go it will be the absence of 
> subclassing. Thank you for clarification.
>
> Regards.
>
> пятница, 14 ноября 2025 г. в 20:58:56 UTC+3, Jason E. Aten: 
>
>> Dear Alex (alex-coder), 
>>
>> Here is an easy rule to remember. There is one, and only one, 
>> way to get dynamic dispatch in Go. That is: calling through an interface.
>>
>> Your example is using embedding, not calling through an interface, so it 
>> is not relevant to
>> how dynamic dispatch works. 
>>
>> You have guessed that Go works like other languages,
>> and unfortunately your guess was wrong, and this has led you to the wrong 
>> conclusion.
>>
>> Embedding will automatically generate methods from the embedded type on 
>> the
>> outer type, but it will not give dynamic dispatch. 
>>
>> As above, the rule to remember is that _only_ 
>> calling-through-an-interface variable gives 
>> dynamic dispatch in Go.
>>
>> A simple demonstration:
>>
>> https://go.dev/play/p/WzhwvLB9VEY
>>
>> Now that is understood, my recommendation is that you should 
>> usually still avoid interfaces for as long as possible, until you
>> absolutely must deploy them, because interfaces 
>> make it harder to debug your program, and can be slower.
>>
>> best wishes,
>> Jason
>>
>> p.s. See also https://github.com/glycerine/thinkgo for other hints.
>>
>> On Friday, November 14, 2025 at 5:33:11 PM UTC alex-coder wrote:
>>
>> пятница, 14 ноября 2025 г. в 20:27:55 UTC+3, alex-coder: 
>>
>> Hi, Brain.
>>
>> the sample is there:  Go Playground - The Go Programming Language 
>> <https://go.dev/play/p/PxUhKHgnfc0>
>>
>> Regards.
>>
>> пятница, 14 ноября 2025 г. в 16:37:54 UTC+3, Brian Candler: 
>>
>> On Friday, 14 November 2025 at 12:13:09 UTC alex-coder wrote:
>>
>> Due to absence in GO dynamic dispatching
>>
>>
>> Not sure what you mean? Method calls on interface values are dynamic 
>> dispatching.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/c7c28ab2-be57-4701-82c0-42a97e99d553n%40googlegroups.com.

Reply via email to