Skip to content

Commit

Permalink
Added check to verify that sufficient args are supplied.
Browse files Browse the repository at this point in the history
Corrected the range to skip Args[0] (which is the command itself)
  • Loading branch information
mandolyte committed Oct 26, 2014
1 parent 1b92c78 commit 756e6b7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion go/receive_logs_direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ func main() {
)
failOnError(err, "Failed to declare a queue")

for _, s := range os.Args {
if len(os.Args) < 2 {
log.Printf("Usage: %s [info] [warning] [error]", os.Args[0])
os.Exit(0)
}
for _, s := range os.Args[1:] {
log.Printf("Binding queue %s to exchange %s with routing key %s", q.Name, "logs_direct", s)
err = ch.QueueBind(
q.Name, // queue name
Expand Down

0 comments on commit 756e6b7

Please sign in to comment.