Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying protoc command #3623

Open
duckbrain opened this issue Dec 18, 2024 · 0 comments
Open

Allow specifying protoc command #3623

duckbrain opened this issue Dec 18, 2024 · 0 comments

Comments

@duckbrain
Copy link
Contributor

Goal: To reduce onboarding and setup I want to be able to run go generate ./... in a newly cloned project and have that work without any other dependencies other than the correct Go version. I also want to keep versions pinned (using go.mod if possible). For goa I can accomplish that by including a go generate comment like the following. This also ensures my project's goa matches the code generator when maintaining many goa-based projects.

//go:generate go run goa.design/goa/v3/cmd/goa gen ...

Problem: If goa needs to launch protoc to generate gRPC, the developer must have protoc installed and the two plugins that goa uses must be in protoc's path. I've been able to get around this by creating a wrapper script that can download the correct version of protoc from GitHub into a cache directory and go install the plugins into that same directory, then execute goa with its PATH prefixed with that directory. Special care must be taken to ensure this works across Windows/Mac/Linux.

Solution: Add a new flag to specify the command to run for protoc. I created https://github.com/duckbrain/goprotoc This is a go runable drop-in replacement for protoc that will also use go run for plugins, You could use -protoc "go generate github.com/duckbrain/goprotoc" (and soon "go tool goprotoc") to get a zero dependency go generate with goa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant