- install golang SDK gomirrors.org
must 1.13+
- install docker
- Discovery by
etcd
more info see https://github.com/etcd-io/etcd
if use consul see https://www.consul.io/
- install Protobuf https://github.com/protocolbuffers/protobuf
- install protoc-gen-micro github.com/micro/protoc-gen-micro
go get -v github.com/golang/protobuf/{proto,protoc-gen-go}
go get -v github.com/micro/protoc-gen-micro
- install micro cli
# Mac OS or Linux
curl -fsSL https://micro.mu/install.sh | /bin/bash
# Windows
powershell -Command "iwr -useb https://micro.mu/install.ps1 | iex"
get docker images micro/micro
page is https://hub.docker.com/r/micro/micro
docker pull micro/micro
- install depends
make dep
- this task will add base depends of this project at project
vendor
folder
lib | version | url |
---|---|---|
github.com/micro/go-micro | v1.16.0 | github.com/micro/go-micro |
github.com/spf13/viper | v1.5.0 | github.com/spf13/viper |
more version info see go.mod
make protoUpdate
etcd
use different cli for run discovery
consul agent -dev
# or
consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul
- run web config UI
micro web
see at http://localhost:8082/ config at http://localhost:8082/client
go run main.go
- test at web ui http://localhost:8082/query
or use curl
curl -v 'http://localhost:8082/rpc' \
-H "Content-Type:application/json" -H "Accept:application/json" \
-d '{"service":"go.micro.restful.demo","method":"Version.Version","request":{"name":"my"}}' \
-X POST