I am reading RabbitMQ tutorial and seeing following code:
forever := make(chan bool)
go func() {
for d := range msgs {
log.Printf("Received a message: %s", d.Body)
}
}()
log.Printf(" [*] Waiting for messages. To exit press CTRL+C")
<-forever
What I am interested in is for d := range msgs
. How does this for loop handle events? eg. At the app start I have only one message in msgs
queue buffer.
Questions:
- How would it process next event?
- 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?