confluentinc / confluentinc/examples
Golang example to consume Confluent Kafka does not contain the go.mod and the build does not work
- Dominant language
- Java
- Stars
- 2.1k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
**Description**
I tried to go through the step by step mentioned in the documentation:
https://docs.confluent.io/platform/current/tutorials/examples/clients/docs/go.html?ajs_aid=7077fcce-0d54-4277-a0c0-50c875f49cd2&ajs_uid=718849
While trying to execute it the error message was triggered:

I realized that there is no `go.mod` in the project, and the import of "./ccloud" is breaking. (Honestly could be an ignorance on my side, I do not know how to use those relative imports)
Then I needed to first create a module with `go mod init anything/r` and `go mod tidy`
**Troubleshooting**
Change That I needed to do in the code to make it work
```
//Change That I needed to do in the code
import (
"anything/r/ccloud"
"encoding/json"
"fmt"
"gopkg.in/confluentinc/confluent-kafka-go.v1/kafka"
"os"
"os/signal"
"syscall"
"time"
)
```
Then after that, I was able to use the example successfully
`./producer -f $HOME/.confluent/librdkafka.config -t test1`
**Environment**
- GitHub branch: 7.2.1-post
- Operating System: Ubuntu 20.04.3 LTS
- Version of Docker: Did not use
- Version of Docker Compose: Did not use
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.