Summary

We have seen how to write a concurrent Singleton using mutexes and channels. While the channels example was more complex, it also shows the core power of Go's concurrency, as you can achieve complex levels of event-driven architectures by simply using channels.

Just keep in mind that, if you haven't written concurrent code in the past, it can take some time to start thinking concurrently in a comfortable way. But it's nothing that practice cannot solve.

We have seen the importance of designing concurrent apps to achieve parallelism in our programs. We have dealt with most of Go's primitives to write concurrent applications, and now we can write common concurrent design patterns.

Get Go Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.