This project demonstrates how to use Go with Apache Kafka using the confluent-kafka-go client library. It includes simple producer and consumer examples, and a Docker Compose setup for running Kafka locally.
following Confluent documentation
- Go 1.22+
- Docker
- Docker Compose
producer.go: Kafka producer exampleconsumer.go: Kafka consumer exampledocker-compose.yml: Local Kafka, Schema Registry, and related servicesgo.mod,go.sum: Go module files
Start the Kafka environment using Docker Compose:
docker-compose up -dinstall go dependencies
go mod tidy- Run the Producer Send random purchase events to the purchases topic:
./out/producer- Run the Consumer Consume and print events from the purchases topic:
./out/consumer