Skip to content

Commit

Permalink
Don't return from example functions
Browse files Browse the repository at this point in the history
go-vet recently added a rule for this it seems.
  • Loading branch information
eapache committed Sep 24, 2015
1 parent 4faee61 commit 39f6444
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@ import (
"testing"
)

func ExampleBroker() error {
func ExampleBroker() {
broker := NewBroker("localhost:9092")
err := broker.Open(nil)
if err != nil {
return err
panic(err)
}

request := MetadataRequest{Topics: []string{"myTopic"}}
response, err := broker.GetMetadata(&request)
if err != nil {
_ = broker.Close()
return err
panic(err)
}

fmt.Println("There are", len(response.Topics), "topics active in the cluster.")

return broker.Close()
if err = broker.Close(); err != nil {
panic(err)
}
}

type mockEncoder struct {
Expand Down

0 comments on commit 39f6444

Please sign in to comment.