Design Patterns [GoF] in Go source code

Hi everyone!
For educational purposes I am inspecting the Go source code/implementation itself on design patterns [GoF]. I have a hard time finding some patterns, as I am new to Go and its not the usual oop language with inheritance and classes etc. So…has someone any ideas where to find design patterns in the source code?

There are many GoF patterns. As you’ve already notices, creational and structural patterns will be hard to find due to the way Go does OOP.

But there are also behavioral patterns. Could you identify any of these?

Thanks for the answer, unfortunately I have not found any, but maybe the Observer pattern is used for signal/notify or async/await pattern with channels…I am struggling but I keep looking.

The concerns that should be addressed in system programming are different than the concerns that need to be taken care of during application programming.

While doing system programming, usually, the raw performance itself is a requirement. In those cases, some unconventional code can be seen there that on the surface is ignoring software development practices. The reason for that in this case is the goal is to squeeze the last drop of the raw performance and be very careful with memory allocation.

On the other hand, during application development, the goal is to stay as close as possible to the ubiquitous language of our domain space and represent it as clearly as possible in our solution space. Applying design patterns and architectural patterns here makes more sense. In the course of doing application development, the raw performance is not as critical as in system-programming.

So, I would argue we should not expect to see much of those designs and practices in the source of the Go itself.

Thats right, I see your point. I did take a look at the list we got from our prof and indeed I found some. Go is using the cache aside pattern with its mchaches. Also I noticed that there is something like a object pool pattern regarding heap allocations and spans. Another 2 are the garbage collector and the locking pattern, of which I did not know they are actually considered as design patterns.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.