streadway/amqp — pull request #48 by streadway (2013-02-13 19:58:58+00:00)
Title: Deadlock by call Connection.Channel() func in range channel amqp.Delivery

The following code is hanging. What's wrong or just I make a mistake? Could you give me a hand? Thanks!

```
package main

import (
"github.com/streadway/amqp"
)

func main() {
conn, err := amqp.Dial("amqp://guest:guest@localhost")
if err != nil {
panic(err)
}
channel, err := conn.Channel()
if err != nil {
panic(err)
}
deliveries, err := queueBind(channel, "hang")
if err != nil {
panic(err)
}
for _ = range deliveries {
hang(conn)
}
}

func hang(conn *amqp.Connection) {
channel, err := conn.Channel()
if err != nil {
panic(err)
}
println(channel)
}

func queueBind(channel *amqp.Channel, name string) (d <-chan amqp.Delivery, err error) {
if err = channel.ExchangeDeclare(name, "fanout", true,
false, false, false, nil); err != nil {
return
}
if _, err = channel.QueueDeclare(name, true, false, false, false, nil); err != nil {
return
}
if err = channel.QueueBind(name, name, name, false, nil); err != nil {
return
}
channel.Publish(name, "", false, false, amqp.Publishing{
Body: []byte("hello world"),
})
return channel.Consume(name, name, false, false, false, false, nil)
}
```