December 2017
Intermediate to advanced
404 pages
9h 28m
English
For connecting to a RabbitMQ broker (or any AMQP broker, for that matter), we recommend that you use the github.com/streadway/amqp library (which is the de facto standard Go library for AMQP). Let's start by installing the library:
$ go get -u github.com/streadway/amqp
You can then start by importing the library into your code. Open a new connection using the amqp.Dial method:
import "github.com/streadway/amqp"
func main() {
connection, err := amqp.Dial("amqp://guest:guest@localhost:5672")
if err != nil {
panic("could not establish AMQP connection: " + err.Error())
}
defer connection.Close()
}
In this case, "amqp://guest:guest@localhost:5672" is the URL of your AMQP broker. Note that the user credentials are embedded ...
Read now
Unlock full access