A sample code in Go to serialize an object in Avro using goavro.
If you want to store your Avro in Kafka, you should serialize your object using with schema registry header information.
Initially, I was using gogen-avro to serialize objects, but the serialization do not include schema registry headers information.
At the end of the day, I decided to select goavro to serialize the object and set header manually.
go get "github.com/linkedin/goavro"
# Build go
cd go-serializer
go build src/serializer.go;
# Generate file
./serializer
# Print json from avro file
cd ../java-serializer
./gradlew run
The output will be {"code": "code code code 1", "amount": 1}