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