–go-grpc_out: protoc-gen-go-grpc: 插件以状态码 1 失败

huangapple go评论101阅读模式
英文:

--go-grpc_out: protoc-gen-go-grpc: Plugin failed with status code 1

问题

当我编译我的proto文件时,出现了以下错误:

protoc-gen-go-grpc: 找不到程序或不可执行
请指定一个绝对路径的程序,或确保该程序在您的PATH系统变量中可用
--go-grpc_out: protoc-gen-go-grpc: 插件返回状态码 1。

我正在使用以下版本:

二进制文件 版本
protoc-gen-go v1.25.0-devel
protoc v3.12.4

我尝试编译这个proto文件:

syntax = "proto3";

option go_package = "proto/";

message GreetingRequest {
  string first_name = 1;
  string last_name = 2;
}
message GreetingResponse{
  string result = 1;
}

service AddService{
  rpc Greet(GreetingRequest) returns (GreetingResponse) {};
}

我使用了以下命令:

protoc \
--proto_path=proto \
--go_out=proto \
--go_opt=paths=source_relative \
--go-grpc_out=proto \
--go-grpc_opt=paths=source_relative \
service.proto

我使用以下命令安装了protoc-gen-go-grpc

go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

但仍然显示这个错误。

英文:

i am getting this error when i compile my proto file:

protoc-gen-go-grpc: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
\--go-grpc_out: protoc-gen-go-grpc: Plugin failed with status code 1.

I am using these versions:

Binary Version
protoc-gen-go v1.25.0-devel
protoc v3.12.4

I have tried to compile this proto file:

syntax = "proto3";

option go_package = "proto/";

message GreetingRequest {
  string first_name = 1;
  string last_name = 2;
}
message GreetingResponse{
  string result = 1;
}

service AddService{
  rpc Greet(GreetingRequest) returns (GreetingResponse) {};
}

I used this command:

protoc \
--proto_path=proto \
--go_out=proto \
--go_opt=paths=source_relative \
--go-grpc_out=proto \
--go-grpc_opt=paths=source_relative \
service.proto

I installed protoc-gen-go-grpc using:

go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

but its still showing this error.

答案1

得分: 2

你好,如果你正在使用Mac M1,可以尝试使用以下命令:

export PATH="$PATH:$(go env GOPATH)/bin"

要使此更改永久生效,你可能需要修改你的~/.zshrc文件并执行source命令。

这个命令是从这里获取的:

https://grpc.io/docs/languages/go/quickstart/

英文:

Hello if you are running on mac m1 try using this command

export PATH="$PATH:$(go env GOPATH)/bin"

to make this change permanent you may have to modify your ~/.zshrc file and source it

got it from here

https://grpc.io/docs/languages/go/quickstart/

huangapple
  • 本文由 发表于 2022年4月1日 20:42:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/71707105.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定