8000 Corrected argument handling · rtoth89/rabbitmq-tutorials@dc5357c · GitHub
[go: up one dir, main page]

Skip to content

Commit dc5357c

Browse files
committed
Corrected argument handling
1 parent 0a1a770 commit dc5357c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

go/receive_logs_topic.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ func main() {
4545
)
4646
failOnError(err, "Failed to declare a queue")
4747

48-
for _, s := range os.Args {
48+
if len(os.Args) < 2 {
49+
log.Printf("Usage: %s [binding_key]...", os.Args[0])
50+
os.Exit(0)
51+
}
52+
for _, s := range os.Args[1:] {
4953
log.Printf("Binding queue %s to exchange %s with routing key %s", q.Name, "logs_topic", s)
5054
err = ch.QueueBind(
5155
q.Name, // queue name

0 commit comments

Comments
 (0)
0