解决go语言安装protoc protocbuf中存在的相关依赖问题
grpc
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
显示红色,找不到包的qingkuang
1、新建grpc存放路径
$ mkdir $GOPATH/src/google.golang.org
2、进入文件夹,下载grpc包
$ cd $GOPATH/src/google.golang.org
$ git clone https://github.com/grpc/grpc-go.git
3、重命名 grpc-go 为 grpc
$ mv grpc-go grpc
protobuf
git clone https://github.com/protocolbuffers/protobuf-go.git
mv protobuf-go protobuf
然后把protobuf文件夹移动到 $GOPATH/src/google.golang.org 目录下
golang设置代理
set http_proxy=socks5://127.0.0.1:1080
$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn,direct
“github.com/micro/go-plugins/registry/consul”
设置 mod 模式和代理
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,https://proxy.golang.org,direct
安装
go get -u -v github.com/golang/protobuf/protoc-gen-go
go get -u -v google.golang.org/grpc
这里若加 -u 选项貌似会报错,就不加了
go get -v github.com/micro/micro/v2
go get -u -v github.com/micro/go-micro/v2
go get -v github.com/micro/micro/v2/cmd/protoc-gen-micro@master
报错问题
查看版本报错:
PS D:CodeCodeToolsGoPathbin> micro help
panic: qtls.ConnectionState not compatible with tls.ConnectionState
goroutine 1 [running]:
github.com/lucas-clemente/quic-go/internal/handshake.init.1()
D:/Code/CodeTools/GoPath/pkg/mod/github.com/lucas-clemente/quic-go@v0.14.1/internal/handshake/unsafe.go:17 +0x139
执行 micro 相关命令报错:
PS C:UsersYC> cd D:CodeCodeToolsGoPathbin
PS D:CodeCodeToolsGoPathbin> micro api --handler=api
panic: qtls.ConnectionState not compatible with tls.ConnectionState
goroutine 1 [running]:
github.com/lucas-clemente/quic-go/internal/handshake.init.1()
D:/Code/CodeTools/GoPath/pkg/mod/github.com/lucas-clemente/quic-go@v0.14.1/internal/handshake/unsafe.go:17 +0x139
这是由于我是从 1.6.2 开始安装 micro 导致,go 版本换成 1.14.15,删除 GoPath 相关文件之后,重新进行下载,问题解决!