First, little disclaimer: concurrency is hard. Even though, someone can tell you that with a great support for concurrency primitives in Go concurrency will become easy. Trivial things will be easy, but you can still end up having problems.

If you are still feeling adventurous, I have some resources for you!

Some time ago, I organized Concurrent programming in Go workshop in Warsaw hackerspace. Slides.

People taking part in the workshop were Go beginners and most of them didn't have much experience in writing concurrent programs. Workshops were interactive, so I have some exercises for you. Exercises start with number 3, because I've omitted the trivial ones (you can still read about them in the slides). They would require you to use your knowledge about concurrency and software design, expect them to be open ended.

Exercise 3 - vending machine

Design a vending machine that will take coins as input and chocolate as output.

Let's imagine that Gophers have coins of value 1, 2 and 5. Gopher can choose the item and then has to insert money and wait for the vending machine to dispense the item.

Exercise 4 - design simple work pipeline

Hackers started working on the new IRC bot. They decided that the bot should support command: ~shoutitinreverse

Your task is to design a following string processing pipeline: put on queue -> strip whitespace -> change to UPPER -> reverse -> print

What additional features could it support?

Exercise 5 - control access to 3D printers

During a busy hackaton 3D printers are heavily used. Write a simulation of hackers trying to access 3D printers.

In the hackerspace, there are 3 3D printers. There are 7 hackers that are interested in using the printers.

If the hacker can't access the printer for more than 5 seconds, he gets annoyed and quits the hackaton. Hackers use printers for random interval from 1 to 10 seconds and usually they need to use the printer at least twice, because nothing is perfect for the first time.

Exercise 6 - hackerspace membership fees

Every month, hackerspace has to pay its bills and every hacker has to pay his or her membership fee.

Requirements: - Hackers in general don't pay their fees the same day every month, it's much more random. - Bills however have to be paid on time. - The board wants monthly reports of the funds.

Use share memory by communication approach (avoid mutexes).


I hope that it would be useful. If you finish those exercises I would love to see your solutions. Exercises were inspired by 3 TRIVIAL CONCURRENCY EXERCISES FOR THE CONFUSED NEWBIE GOPHER.

Have fun learning Go!