How to Use RabbitMQ in Go with amqp091-go

Web
Connect to RabbitMQ in Go by dialing the server URL and publishing messages via an amqp091-go channel.

You connect to RabbitMQ in Go by importing github.com/streadway/amqp, dialing the server, and opening a channel to publish or consume messages.

import "github.com/streadway/amqp"

conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/")
if err != nil { panic(err) }
defer conn.Close()

ch, err := conn.Channel()
if err != nil { panic(err) }
defer ch.Close()

err = ch.Publish("", "my-queue", false, false, amqp.Publishing{Body: []byte("Hello")})
if err != nil { panic(err) }