Skip to content

Instantly share code, notes, and snippets.

@chris001177
Created July 28, 2019 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris001177/973207a3408e9c4e708ea3d88ddb1e48 to your computer and use it in GitHub Desktop.
Save chris001177/973207a3408e9c4e708ea3d88ddb1e48 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/Shopify/sarama"
)
func main() {
config := sarama.NewConfig()
config.Consumer.Return.Errors = true
//kafka end point
brokers := []string{"localhost:9093"}
//get broker
cluster, err := sarama.NewConsumer(brokers, config)
if err != nil {
panic(err)
}
defer func() {
if err := cluster.Close(); err != nil {
panic(err)
}
}()
//get all topic from cluster
topics, _ := cluster.Topics()
for index := range topics {
fmt.Println(topics[index])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment