go get-v -u google.golang.org/grpc // gRPC
go get-v -u github.com/golang/protobuf/protoc-gen-go // 安装protoc go插件
go get-v -u github.com/micro/go-micro // Micro 框架
go get-v -u github.com/micro/protoc-gen-micro // protoc micro插件, 用于通过.proto文件生成.micro.go代码文件
go get-v -u github.com/micro/micro // micro工具包
其中有几个会生成可执行程序. micro.exe, protoc-gen-go.exe, protoc-gen-micro.exe (没错, 我是在 windows 中玩的)
安装其他依赖, 不然在 run 下面的 service.go 时会报找不到这些包的错误.
go get-v -u github.com/hashicorp/go-cleanhttp
go get-v -u github.com/hashicorp/go-rootcerts
go get-v -u github.com/hashicorp/memberlist
go get-v -u github.com/hashicorp/serf/coordinate
go get-v -u github.com/lucas-clemente/quic-go
go get-v -u github.com/mitchellh/hashstructure
go get-v -u github.com/mitchellh/mapstructure
创建 proto 文件. user.proto
syntax = "proto3";
service User {
rpc Hello(Request) returns (Response) {}
}
message Request {
string name = 1;
}
message Response {
string msg = 1;
}
F:a_link_workspacegoGoWinEnv_Test01srcGoMicrotest001srv(master -> origin)
λ go run service.go
2019/09/2802:04:58 Transport [http] Listening on [::]:538022019/09/2802:04:58 Broker [http] Connected to [::]:538032019/09/2802:04:58 Registry [mdns] Registering node: user-d9a8a8db-28c6-424f-ab2a-843f80049cea