使用protoc-gen-go创建一个.pb.go,导入google / golang,但找不到包 [英] Using protoc-gen-go creates a .pb.go that imports google/golang but can't find package

查看:3230
本文介绍了使用protoc-gen-go创建一个.pb.go,导入google / golang,但找不到包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用原始发行版来编译 C Protocol Buffers 转换为 Golang 几乎可以去安装这个软件包,但是我得到这个错误:

找不到软件包 google / protobuf



但我无法在任何地方找到这个软件包进行下载,有谁可以告诉我该怎么做?感谢。



我按照以下所有步骤从这里



然后运行 protoc --go_out =。 * .proto ,我得到我所有的文件,但是错误的 proto import

解决方案

as @poopoothegoriall说,请使用github中的protobuf,而不是code-google。生成的.pb.go文件将导入github.com/golang/protobuf/proto



更新
这是我的步骤:


  1. make install 项目 https://github.com/google/protobuf.git

  2. 去获取 https:// github。 com / golang / protobuf

  3. 通过 protoc --go_out =生成go源文件。 xxx.proto


I'm using protoc-gen-go to compile C Protocol Buffers into Golang which works great and I can almost go install the package but I get this error:

cannot find package "google/protobuf"

but I cannot find this package anywhere to download, can anybody tell me what I should do with this? Thanks.

I'm following all steps to doing it from here

then I run protoc --go_out=. *.proto and I get all my files, but the wrong proto import

解决方案

as @poopoothegoriall said, please use the protobuf from github, other than code-google. the generated .pb.go file will import "github.com/golang/protobuf/proto"

UPDATE this is my steps:

  1. make install project https://github.com/google/protobuf.git
  2. go get https://github.com/golang/protobuf
  3. generate the go source by protoc --go_out=. xxx.proto

这篇关于使用protoc-gen-go创建一个.pb.go,导入google / golang,但找不到包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆