I have a getQueue()
function to create a connection and channel for my Go client to a RabbitMQ instance. I have this code for the aforementioned function:
func getQueue() (*amqp.Connection, *amqp.Channel, *amqp.Queue) {
conn, err := amqp.Dial("amqp://ayman@localhost:5672")
fallOnError(err, "Fail to connect")
ch, err := conn.Channel()
fallOnError(err, "Fail to open channel")
q, err := ch.QueueDeclare("hello",
false, //durable
false, //autoDelete
false, //exclusive
false, //noWait
nil) //args
fallOnError(err, "Fail to delare a queue")
}
I am getting this error Missing return at end of function
for the same.
I tried using return keyboard at the end of the function, but then I get this error:
not enough arguments to return
have ()
want (*amqp.Connection, *amqp.Channel, *amqp.Queue)
The source video I was referring did not have any such issues.
I am using Ubuntu machine with Go version go1.11.4 linux/amd64
. I am using Atom editor with go-lang
tools package installed.
EDIT
The solution is that I needed 3 parameters to return
return conn,ch,&q
solved my issue.