Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
kafka
✓ github.com/ONSdigital/dp-kafka/v2
Create a Kafka producer and send a message.
package main
import (
"context"
"log"
"github.com/ONSdigital/dp-kafka/v2"
)
func main() {
ctx := context.Background()
config := &kafka.Config{BrokerAddrs: []string{"localhost:9092"}}
producer, err := kafka.NewProducer(ctx, config)
if err != nil {
log.Fatal(err)
}
defer producer.Close(ctx)
producer.Send(ctx, "topic", []byte("message"))
}
Debug
Known issues
No known issues recorded.
Upgrade
Version history
2.8.0latest on pkg.go.dev
Audit
Dependencies
No dependency data recorded yet.