Get list of topics in kafka Golang

Get list of topics in kafka Golang

There are different library available in Golang to publish and subscribe topics in kafka. In this example, we are using sarama library to list all the available topic at kafka broker.

To get sarama library, run below command.

Code to list all topics.

Running above code produces below output on my machine. Because, I have two topics(Test – 1 and Test-2) available with my kafka broker.

 

Leave a Reply

Your email address will not be published. Required fields are marked *