New Template

micro new [service]

The micro new command is a quick way to generate boilerplate templates for micro services.

Usage

Create a new service by specifying a directory path relative to your $GOPATH

  1. micro new github.com/micro/foo

Here it is in action

  1. micro new github.com/micro/foo
  2. creating service go.micro.srv.foo
  3. creating /Users/asim/checkouts/src/github.com/micro/foo
  4. creating /Users/asim/checkouts/src/github.com/micro/foo/main.go
  5. creating /Users/asim/checkouts/src/github.com/micro/foo/handler
  6. creating /Users/asim/checkouts/src/github.com/micro/foo/handler/example.go
  7. creating /Users/asim/checkouts/src/github.com/micro/foo/subscriber
  8. creating /Users/asim/checkouts/src/github.com/micro/foo/subscriber/example.go
  9. creating /Users/asim/checkouts/src/github.com/micro/foo/proto/example
  10. creating /Users/asim/checkouts/src/github.com/micro/foo/proto/example/example.proto
  11. creating /Users/asim/checkouts/src/github.com/micro/foo/Dockerfile
  12. creating /Users/asim/checkouts/src/github.com/micro/foo/README.md
  13. download protobuf for micro:
  14. go get github.com/micro/protobuf/{proto,protoc-gen-go}
  15. compile the proto file example.proto:
  16. protoc -I/Users/asim/checkouts/src \
  17. --go_out=plugins=micro:/Users/asim/checkouts/src \
  18. /Users/asim/checkouts/src/github.com/micro/foo/proto/example/example.proto

Options

Specify more options such as namespace, type, fqdn and alias

  1. micro new --fqdn com.example.srv.foo github.com/micro/foo

Help

  1. NAME:
  2. micro new - Create a new micro service
  3. USAGE:
  4. micro new [command options] [arguments...]
  5. OPTIONS:
  6. --namespace "go.micro" Namespace for the service e.g com.example
  7. --type "srv" Type of service e.g api, srv, web
  8. --fqdn FQDN of service e.g com.example.srv.service (defaults to namespace.type.alias)
  9. --alias Alias is the short name used as part of combined name if specified