NAME:
micro new - Create a service template
USAGE:
micro new [command options][arguments...]
OPTIONS:
--namespace value Namespace for the service e.g com.example (default: "go.micro")
--type value Type of service e.g api, fnc, srv, web (default: "srv")
--fqdn value FQDN of service e.g com.example.srv.service (defaults to namespace.type.alias)
--alias value Alias is the short name used as part of combined name if specified
--plugin value Specify plugins e.g --plugin=registry=etcd:broker=nats or use flag multiple times
--gopath Create the servicein the gopath. Defaults to true.
1.srv服务创建
micro new --type "srv" micro/rpc/srv
服务创建的所在位置
Creating service go.micro.srv.srv in /home/wyf/workspace/go/src/micro/rpc/srv
.
主函数
├── main.go
生成器
├── generate.go
插件
├── plugin.go
被调用函数实现
├── handler
│ └── srv.go
订阅
├── subscriber
│ └── srv.go
proto 协议文件
├── proto/srv
│ └── srv.proto
docker镜像编译文件
├── Dockerfile
编译文件
├── Makefile
├── README.md
└── go.mod
下载插件
download protobuf for micro:
brew install protobuf
go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
go get -u github.com/micro/protoc-gen-micro
compile the proto file srv.proto:
进入项目命令
cd /home/wyf/workspace/go/src/micro/rpc/srv
protobuf编译命令
protoc --proto_path=.:$GOPATH/src --go_out=. --micro_out=. proto/srv/srv.proto
Micro-服务创建获取帮助1.srv服务创建2.web服务创建获取帮助micro new --helpNAME: micro new - Create a service templateUSAGE: micro new [command options] [arguments...]OPTIONS: --namespace value Namespace f...