Confluent has their own repo for examples
https://github.com/confluentinc/confluent-kafka-go/blob/master/examples/confluent_cloud_example/confluent_cloud_example.go
Extract
bootstrapServers = "<BOOTSTRAP_SERVERS>"
ccloudAPIKey = "<CCLOUD_API_KEY>"
ccloudAPISecret = "<CCLOUD_API_SECRET>"
schemaRegistryAPIEndpoint = "<CCLOUD_SR_ENDPOINT>"
schemaRegistryAPIKey = "<CCLOUD_SR_API_KEY>"
schemaRegistryAPISecret = "<CCLOUD_SR_API_SECRET>"
)
func main() {
topic := "go-test-topic"
createTopic(topic)
// Produce a new record to the topic...
producer, err := kafka.NewProducer(&kafka.ConfigMap{
"bootstrap.servers": bootstrapServers,
"sasl.mechanisms": "PLAIN",
"security.protocol": "SASL_SSL",
"sasl.username": ccloudAPIKey,
"sasl.password": ccloudAPISecret})
if err != nil {
panic(fmt.Sprintf("Failed to create producer: %s", err))
}
client, err := schemaregistry.NewClient(schemaregistry.NewConfigWithAuthentication(
schemaRegistryAPIEndpoint,
schemaRegistryAPIKey,
schemaRegistryAPISecret))