其他分享
首页 > 其他分享> > go micro v1.9.1 安装

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。

进入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下载

标签:protoc,micro,github,v1.9,go,com,gen
来源: https://www.cnblogs.com/xiaochuizi/p/11386876.html