Protobuf with Go

Generate Go code from Protobuf definitions using the protoc compiler and the protoc-gen-go plugin.

Use the go tool to generate Go code from .proto files by running protoc with the Go plugin. First, install the plugin, then run the compiler with the --go_out flag pointing to your output directory.

go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
protoc --go_out=. --go_opt=paths=source_relative *.proto

This generates .pb.go files containing the proto definitions ready for import in your Go project.