Important Notice: CloudKarafka is shutting down. Read all about it in our End of Life Announcement


There are two very good libraries for Go, one is Sarama and then we have confluent-kafka-go. Sarama is a pure Go library and confluent-kafka-go is a wrapper around the excellent librdkafka.

We recommend using confluent_kafka_go since it support authentication with SASL SCRAM which is what we use at CloudKarafka.

First thing that you have to do is connect to the Kafka server. You can get all the connection variables you need from the provider you used to create the CloudKarafka instance.

Consumer example in Go:

c, _ := kafka.NewConsumer(config)
_ = c.Subscribe(topic, nil)
run := true
for run == true {
    select {
    case ev := <-c.Events():
        switch e := ev.(type) {
        case *kafka.Message:
            fmt.Printf("%% Message on %s: %s\n", e.TopicPartition, string(e.Value))

The complete code example can be found here: