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