加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

golang protoc grpc编译没效果解决

发布时间:2020-12-16 18:19:09 所属栏目:大数据 来源:网络整理
导读:1、下载github.com/golang/protobuf https://github.com/golang/protobuf 放到$GOPATN/src/github.com/golang目录下 2、安装grpc gogetgoogle.golang.org/grpc 3、安装proto goget-ugithub.com/golang/protobuf/proto goget-ugithub.com/golang/protobuf/pro

1、下载github.com/golang/protobuf

https://github.com/golang/protobuf 放到$GOPATN/src/github.com/golang目录下

2、安装grpc

gogetgoogle.golang.org/grpc

3、安装proto

goget-ugithub.com/golang/protobuf/proto

goget-ugithub.com/golang/protobuf/protoc-gen-go

编译grpc/examples/helloworld/helloworld/下的proto文件

protoc --go_out=plugins=grpc:. helloworld.proto

如果编出来的没有加载grpc库,可能是protoc-gen-go文件路径不对

查找whereisprotoc-gen-go 会发现这个文件有两个目录:

/usr/bin/protoc-gen-go 和 $GOPATH/bin/protoc-gen-go

这时把 $GOPATH/bin目录下的文件替换到/usr/bin/目录下再试就可以了

主要原因是protoc编译时从$PATH中首先访问/usr/bin目录,找到了protoc-gen-go就直接使用了,而goget-ugithub.com/golang/protobuf/protoc-gen-go安装时安装到了$GOPATH/bin目录下

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读