github.com/QuangHoangHao/kafka-go@v0.4.36/example_writer_test.go (about) 1 package kafka_test 2 3 import ( 4 "context" 5 6 "github.com/QuangHoangHao/kafka-go" 7 ) 8 9 func ExampleWriter() { 10 w := &kafka.Writer{ 11 Addr: kafka.TCP("localhost:9092"), 12 Topic: "Topic-1", 13 } 14 15 w.WriteMessages(context.Background(), 16 kafka.Message{ 17 Key: []byte("Key-A"), 18 Value: []byte("Hello World!"), 19 }, 20 ) 21 22 w.Close() 23 }