API Reference

kafka-go

A Kafka library for Go with both low-level connection and high-level Reader and Writer APIs.

Official Documentation ↗
CompatibilityThis documentation covers version v0.4. Check the official docs for the latest API surface.

Installation

gogo get github.com/segmentio/kafka-go

Methods

kafka-go abstracts producer and consumer mechanics behind Writer and Reader types.

Key Features

  • High-level Reader and Writer
  • Consumer groups via GroupID
  • Balancer and batching configuration

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://cdn.jsdelivr.net/gh/segmentio/kafka-go@latest/README.md · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:50:35.309Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

FAQ

How do I commit offsets?
Reader commits automatically by default; use CommitMessages for manual control after processing.
What does GroupID enable?
It turns the reader into a consumer-group member, so partitions are distributed across instances.
Is Writer safe for concurrent use?
Yes, but batching and async settings affect throughput and ordering; tune based on durability needs.