chirpnest/mq.go
2019-06-28 16:27:19 +08:00

25 lines
391 B
Go

package main
import (
"github.com/streadway/amqp"
)
func Open(c *MQClient) error {
var err error
c.Connection, err = amqp.Dial("amqp://" + c.User + ":" + c.Password + "@" + c.Host + "/" + c.Path)
if err != nil {
c.Connection.Close()
return err
}
c.Channel, err = c.Connection.Channel()
if err != nil {
c.Channel.Close()
c.Connection.Close()
return err
}
return err
}