grpc protobuf doc

grpc 

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

https://github.com/grpc/grpc-go/tree/master/examples/route_guide

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

 

Example code and setup 

The example code for our tutorial is in grpc/grpc-go/examples/route_guide. To download the example, clone the grpc-go repository by running the following command:

https://www.jianshu.com/p/8856b9408bbf

环境安装

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

1.go download
https://golang.google.cn/dl/

2.protoc    从release网址直接下载protoc.exe

https://github.com/protocolbuffers/protobuf
https://github.com/protocolbuffers/protobuf/releases

https://github.com/google/protobuf/releases

https://repo1.maven.org/maven2/com/google/protobuf/protoc/
https://repo1.maven.org/maven2/com/google/protobuf/protoc/3.12.3/


下载之后重命名为proto, 放在go的bin目录下,方便path的环境变量能找到

3.proto-gen-go 从网络获取
go get -u github.com/golang/protobuf/proto

运行以下命令,在GOPATH中的bin目录会找到protoc-gen-go.exe
go get -u github.com/golang/protobuf/protoc-gen-go

代码位置: https://github.com/golang/protobuf 


4.使用proto生成go
protoc --go_out=plugins=grpc:. helloworld.proto
=========================================================================

Example Code of GRPC:

https://github.com/grpc/grpc-go

============================

1.go
https://golang.google.cn/dl/

2.https://www.jianshu.com/p/20ed82218163

=====================

1.proxy go daim 代理设置方法
https://blog.csdn.net/qq_37822034/article/details/106689613
https://goproxy.cn/   , https://goproxy.io

C:\Users\abctest>go env -w GO111MODULE=on

C:\Users\abctest>go env -w GOPROXY=https://goproxy.cn,direct

C:\Users\abctest>go get -u github.com/golang/protobuf/proto
C:\Users\abctest>go get -u github.com/golang/protobuf/protoc-gen-go

==========================================
E:\02020\exam>go build main.go
main.go:27:2: cannot find module providing package google.golang.org/grpc: working directory is not part of a module

go env -w GO111MODULE=on
E:\02020\exam>go mod init main  解决生成了main.mod

---------
在GOROOT的 E:\02020\go\src\helloworld\com.my.org\test 放置 go文件
main.go:28:2: package helloworld/com.my.org/test is not in GOROOT (E:\02020\go\src\helloworld\com.my.org\test)

---------------------------------------==========

ref:

https://studygolang.com/articles/14054 

https://www.jianshu.com/p/ec3e75e5aad1 
https://www.jianshu.com/p/20ed82218163 

==========================================

Prerequisites 

  • Go, any one of the three latest major releases of Go.

    For installation instructions, see Go’s Getting Started guide.

  • Protocol buffer compilerprotocversion 3.

    For installation instructions, see Protocol Buffer Compiler Installation.

  • Go plugin for the protocol compiler:

    1. Install the protocol compiler plugin for Go (protoc-gen-go) using the following command:

      $ export GO111MODULE=on  # Enable module mode
      $ go get github.com/golang/protobuf/protoc-gen-go
      
    2. Update your PATH so that the protoc compiler can find the plugin:

      $ export PATH="$PATH:$(go env GOPATH)/bin"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值