Created
July 28, 2019 07:28
-
-
Save chris001177/973207a3408e9c4e708ea3d88ddb1e48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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