drugs3550
2019-05-24 07:31
浏览 99
已采纳

无法在ubuntu中为golang编译原始文件

I've installed these packages:

google.golang.org/grpc

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

and exported path like this:

export PATH=$PATH:/usr/local/go/bin

when I try compile proto file with protoc command, I see command not found error:

protoc --go_out=. helloworld/helloworld.proto 

zsh: command not found: protoc

my project path is like: /home/my-username/go/src/github.com/my-username/helloworld

my go version: go1.12.5

and I use ubuntu 18.04

When I install it with binary file it works, but compiled go file does not contain some functions like: RegisterGreeterServer or NewGreeterClient

图片转代码服务由CSDN问答提供 功能建议

我已经安装了以下软件包:

google.golang .ORG / GRPC

<强> github.com/golang/protobuf/protoc-gen-go

并像这样导出路径:

  export PATH = $ PATH:/ usr / local / go / bin 
   
 
 

当我尝试使用 protoc 命令编译proto文件时,我看到命令找不到错误:

  protoc --go_out =。  helloworld / helloworld.proto 
 
zsh:找不到命令:protoc 
   
 
 

我的项目路径是: / home / my-username / go / src / github.com / my-username / helloworld

我的go版本:go1.12.5

我使用ubuntu 18.04 < / p>

当我使用二进制文件安装它时,它可以工作,但是编译后的go文件不包含某些功能,例如:RegisterGreeterServer或NewGreeterClient

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • dpquu9206 2019-05-24 12:49
    最佳回答

    Finally with help of Amit, I installed protoc. but when I compiled proto file with this command

    protoc --go_out=. add/add.proto    
    

    go compiled file did not contain some functions like: RegisterGreeterServer or NewGreeterClient for instance.

    by this reply I found out issue and added plugins=grpc, then tried this command and it worked:

    protoc --go_out=plugins=grpc:. add/add.proto
    
    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题