Skip to content

Commit

Permalink
Merge pull request #539 from Shopify/fix-examples
Browse files Browse the repository at this point in the history
Don't return from example functions
  • Loading branch information
eapache committed Sep 24, 2015
2 parents 4faee61 + 39f6444 commit 6f369be
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 6f369be

Please sign in to comment.