go micro v1.9.1 安装

1. 安装protoc-gen-micro

1) protoc

https://github.com/protocolbuffers/protobuf/releases下载编译好的版本protoc-3.9.1-win64.zip

2) protoc的go插件protoc-gen-go

GIT_TAG="v1.2.0" # change as needed
go get -d -u github.com/golang/protobuf/protoc-gen-go
git -C "$(go env GOPATH)"/src/github.com/golang/protobuf checkout $GIT_TAG
go install github.com/golang/protobuf/protoc-gen-go

也可以直接到https://github.com/golang/protobuf/tree/v1.3.2下载。

离线下载需要手动编译。

进入$GOPATH/src/github.com/golang/protobuf/protoc-gen-go

go build -o protoc-gen-go main.go

3) go get github.com/micro/protoc-gen-micro

若开发环境无法上网,可以直接在https://github.com/micro/protoc-gen-micro/tree/v0.8.0下载

离线下载需要手动编译,类似protoc-gen-go。

扫描二维码关注公众号,回复: 7070543 查看本文章

进入src/github.com/micro/protoc-gen-micro

go build -o protoc-gen-micro main.go

2. 服务发现

v1.9.1版本默认的服务发现改为mDNS,无需额外安装。

若想用其它方式,可参考https://micro.mu/docs/go-micro.html

Consul
Consul can be used as an alternative service discovery system.
Discovery is pluggable. Find plugins for etcd, kubernetes, zookeeper and more in the micro/go-plugins repo.
Install guide
Pass --registry=consul to any command or the enviroment variable MICRO_REGISTRY=consul
MICRO_REGISTRY=consul go run main.go

3. 安装go micro

go get -u -v github.com/micro/go-micro 或到https://github.com/micro/go-micro/tree/v1.9.1下载

猜你喜欢

转载自www.cnblogs.com/xiaochuizi/p/11386876.html