Browse Source

tweak broker example

Evan Huus 12 năm trước cách đây
mục cha
commit
cb8190ccd7
1 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 4 2
      broker_test.go

+ 4 - 2
broker_test.go

@@ -145,14 +145,16 @@ func ExampleBroker() error {
 	if err != nil {
 		return err
 	}
+	defer broker.Close()
 
 	request := MetadataRequest{Topics: []string{"myTopic"}}
 	response, err := broker.GetMetadata("myClient", &request)
+	if err != nil {
+		return err
+	}
 
 	fmt.Println("There are", len(response.Topics), "topics active in the cluster.")
 
-	broker.Close()
-
 	return nil
 }