Introduction to Concurrency in Go: Gopher Farm

Introduction to Concurrency in Go: Gopher Farm

5 years ago
Anonymous $fWzGa1uP8i

https://medium.com/@olena_stoliarova/introduction-to-concurrency-in-go-gopher-farm-3aa23f253420

Concurrency can be very tricky for beginners. Reading articles about gophers loading ore and looking at animations that represent goroutines is what helped me a lot when I started learning Go. However, there is a gap between these beginner-friendly articles and real-world projects where you often cannot use familiar analogs. I totally agree that practice is the best way to learn things and after you read some theory you should try new things out yourself. That is why I adore programming kata. Today I want to describe a step-by-step solution to a very funny one I had to solve during a job interview.

The task is as follows: you receive a JSON string that represents a farm where gophers live (sleep and eat actually) and the amount of food in units (perhaps grams as gophers are small animals) these gophers have in the barn. As no more food grows on the farm, our gophers will die one by one when they have nothing to eat. If this is too sad for you, feel free to code Chapter 2 where food trucks come to the farm and gohpers breed.