Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Minor fixes to example code in README.md
  • Loading branch information
blinktag committed Oct 5, 2020
commit a5adfe4517571abb5d4a98790df67779f7b8bd9e
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ import (

func main() {
r, err := rabbit.New(&rabbit.Options{
&Options{
URL: "amqp://localhost",
QueueName: "my-queue",
ExchangeName: "messages",
RoutingKey: "messages",
}
URL: "amqp://localhost",
QueueName: "my-queue",
ExchangeName: "messages",
RoutingKey: "messages",
})
if err != nil {
log.Fatalf("unable to instantiate rabbit: %s", err)
Expand All @@ -54,7 +52,7 @@ func main() {
}

// Consume once
if err := r.ConsumeOnce(nil, func(amqp.Delivery) {
if err := r.ConsumeOnce(nil, func(amqp.Delivery) error {
fmt.Printf("Received new message: %+v\n", msg)
}); err != nil {
log.Fatalf("unable to consume once: %s", err),
Expand All @@ -65,7 +63,7 @@ func main() {
// Consume forever (blocks)
ctx, cancel := context.WithCancel(context.Background())

r.Consume(ctx, nil, func(msg amqp.Delivery) {
r.Consume(ctx, nil, func(msg amqp.Delivery) error {
fmt.Printf("Received new message: %+v\n", msg)

numReceived++
Expand Down
9 changes: 9 additions & 0 deletions rabbit.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>