1. How would it process next event?

Beside iteration over basic data structures, range in GoLang can also iterate over values received from a channel. Range iterates over each element as it's received from queue and ends only when the channel is closed. The next iteration will happen when the channel (msgs) will receive a value

msgs <- message
  1. After some playing around with this code I found that it could stuck on log.Printf line and wouldn't process events anymore. What can be a reason?
forevermsgs

Either

  1. send message through the msgs channel

    msgs <- message

or

forever

It seems like the solution is designed to wait and asynchronously process messages through a channel.