go
build_error
ai_generated
true
protoc-gen-go: 找不到程序或不可执行
protoc-gen-go: program not found or is not executable
ID: go/protoc-gen-go-missing-plugin
80%修复率
89%置信度
0证据数
2024-01-08首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| google.golang.org/protobuf v1.28+ | active | — | — | — |
根因分析
protoc 在 PATH 上找不到 protoc-gen-go 插件二进制。它通过 go install 安装,但 $GOPATH/bin 未加入 PATH,或二进制名称不对。
English
protoc cannot locate the protoc-gen-go plugin binary on PATH. It is installed via go install but $GOPATH/bin is not on PATH, or the binary name is wrong.
解决方案
-
95% 成功率
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest export PATH="$PATH:$(go env GOPATH)/bin" which protoc-gen-go
-
90% 成功率
protoc --plugin=protoc-gen-go=$(go env GOPATH)/bin/protoc-gen-go \ --go_out=. user.proto
无效尝试
常见但无效的做法:
-
80% 失败
The error is about the Go plugin, not the protoc compiler. Reinstalling protoc does not add protoc-gen-go to PATH.
-
75% 失败
protoc resolves plugins by name on PATH; passing a binary path as an output directory is invalid.