简体   繁体   English

错误消息:protoc-gen-go:插件失败,状态码为 1

[英]Error message:protoc-gen-go: Plugin failed with status code 1

This is not a duplicate question这不是重复的问题

First, I made sure I have the following configuration:首先,我确保我具有以下配置:

  1 export GOPATH=/Users/chezixin/go
  2 export GOBIN=/Users/chezixin/go/bin
  3 
  4 export GO111MODULE=on
  5 # 123
  6 export GOPROXY=https://goproxy.cn
  7 
  8 
  9 export PATH="$PATH:/Applications/Postgres.app/Contents/Versions/12/bin:/Users/chezixin/flutterSDK/flutter/bin:/usr/local/go/bin:$GOPATH:$GOBIN"
 10


 czxmac:~ chezixin$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:
/sbin:/Applications/VMwareFusion.app/Contents/Public:
/Applications/Postgres.app/Contents/Versions/latest/bin:
/Applications/Postgres.app/Contents/Versions/12/bin:
/Users/chezixin/flutterSDK/flutter/bin:/usr/local/go/bin:
/Users/chezixin/go:/Users/chezixin/go/bin':
/Users/chezixin/Go/bin:/Applications/Postgres.app/Contents/Versions/12/bin:
/Users/chezixin/flutterSDK/flutter/bin:
/usr/local/go/bin:/Users/chezixin/go:
/Users/chezixin/go/bin:/Users/chezixin/Go/bin

Already installed: go get -u google.golang.org/grpc已经安装:go get -u google.golang.org/grpc

look protoc:看协议:

czxmac:~ chezixin$ protoc --version
libprotoc 3.11.1

Protoc-gen-go is installed and exists in $ GOPATH/bin protoc-gen-go 已安装并存在于 $GOPATH/bin

go get -u github.com/golang/protobuf/protoc-gen-go go get -u github.com/golang/protobuf/protoc-gen-go

problem: When I execute the following command问题:当我执行以下命令时

$ protoc --go_out=plugins=grpc:. *.proto

An error occurred:发生错误:

protoc-gen-go: 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_out: protoc-gen-go: Plugin failed with status code 1.

Where is the problem, please master guidance.问题出在哪里,请高手指点。

This issue is related with your PATH variable, please set it again.此问题与您的 PATH 变量有关,请重新设置。 I can see a typo of an extra trailing apostrophe(') in this line of PATH variable.我可以在 PATH 变量的这一行中看到一个额外的尾随撇号(')的错字。 /Users/chezixin/go:/Users/chezixin/go/bin': /Users/车子心/go:/Users/车子心/go/bin':

Try updating it to /Users/chezixin/go:/Users/chezixin/go/bin:尝试将其更新为 /Users/chezixin/go:/Users/chezixin/go/bin:

For anyone facing a similar issue, but it was not the case of an invalid PATH variable, I very much sympathize with you.对于面临类似问题的任何人,但不是 PATH 变量无效的情况,我非常同情你。

I realized that I had to install the compiler (again?) before it started working.我意识到我必须在编译器开始工作之前(再次?)安装它。 I hadn't installed it before, but it appeared to already be downloaded.我之前没有安装它,但它似乎已经下载了。 I guess I had to install it again or update it.我想我必须重新安装或更新它。

I personally was using betterproto , and I followed the instructions here to install it with the protoc plugin and try out their example.我个人使用的是betterproto ,我按照此处的说明使用protoc插件安装它并尝试他们的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM