https://github.com/github/proto-gen-go
A 'go generate' script to generate Go files from .proto interfaces
https://github.com/github/proto-gen-go
Last synced: 5 months ago
JSON representation
A 'go generate' script to generate Go files from .proto interfaces
- Host: GitHub
- URL: https://github.com/github/proto-gen-go
- Owner: github
- Created: 2021-09-07T16:04:15.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-01-31T20:01:11.000Z (about 1 year ago)
- Last Synced: 2025-01-31T21:18:20.875Z (about 1 year ago)
- Language: Go
- Size: 35.2 KB
- Stars: 23
- Watchers: 6
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# proto-gen-go
[](https://github.com/github/proto-gen-go/actions/workflows/docker.yaml)
This tool is a thin wrapper around protoc, the protocol compiler. It
makes it easy to reliably generate and update Go definitions for
messages and services defined in .proto files. It uses a docker
container with explicitly versioned dependencies to ensure maximum
reproducibility and minimum side effects.
In your Go project's proto directory, add a `gen.go` file with the following contents:
```go
package proto
//go:generate sh -c "go run github.com/github/proto-gen-go@ [flags] [--] [protoc flags] [proto files]"
```
(The `go run module@version` command requires Go 1.23 or later.)
Now, when you run `go generate` in your proto directory, the script
will re-run the protocol compiler on all .proto files, and generate go
files into the obvious relative locations. Commit them along with your
source code.