25 lines
394 B
Go
25 lines
394 B
Go
package main
|
|
|
|
import (
|
|
"github.com/streadway/amqp"
|
|
)
|
|
|
|
func (c *MQClient) Open() 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
|
|
}
|