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 compiler,
protoc
, version 3.For installation instructions, see Protocol Buffer Compiler Installation.
-
Go plugin for the protocol compiler:
-
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
-
Update your
PATH
so that theprotoc
compiler can find the plugin:$ export PATH="$PATH:$(go env GOPATH)/bin"
-