github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/docs/v2/framework/new.md (about)

     1  ---
     2  title: New Template
     3  keywords: new
     4  tags: [new]
     5  sidebar: home_sidebar
     6  permalink: /new
     7  summary: 
     8  ---
     9  
    10  # micro new [service]
    11  
    12  The **micro new** command is a quick way to generate boilerplate templates for micro services.
    13  
    14  ## Usage
    15  
    16  Create a new service by specifying a directory path relative to your $GOPATH
    17  
    18  ```
    19  micro new github.com/micro/foo
    20  ```
    21  
    22  Here it is in action
    23  
    24  ```
    25  micro new github.com/micro/foo
    26  
    27  creating service go.micro.srv.foo
    28  creating /Users/asim/checkouts/src/github.com/micro/foo
    29  creating /Users/asim/checkouts/src/github.com/micro/foo/main.go
    30  creating /Users/asim/checkouts/src/github.com/micro/foo/handler
    31  creating /Users/asim/checkouts/src/github.com/micro/foo/handler/example.go
    32  creating /Users/asim/checkouts/src/github.com/micro/foo/subscriber
    33  creating /Users/asim/checkouts/src/github.com/micro/foo/subscriber/example.go
    34  creating /Users/asim/checkouts/src/github.com/micro/foo/proto/example
    35  creating /Users/asim/checkouts/src/github.com/micro/foo/proto/example/example.proto
    36  creating /Users/asim/checkouts/src/github.com/micro/foo/Dockerfile
    37  creating /Users/asim/checkouts/src/github.com/micro/foo/README.md
    38  
    39  download protobuf for micro:
    40  
    41  go get github.com/micro/protobuf/{proto,protoc-gen-go}
    42  
    43  compile the proto file example.proto:
    44  
    45  protoc -I/Users/asim/checkouts/src \
    46  	--go_out=plugins=micro:/Users/asim/checkouts/src \
    47  	/Users/asim/checkouts/src/github.com/micro/foo/proto/example/example.proto
    48  
    49  ```
    50  
    51  ### Options
    52  
    53  Specify more options such as namespace, type, fqdn and alias
    54  
    55  ```
    56  micro new --fqdn com.example.srv.foo github.com/micro/foo
    57  ```
    58  
    59  ### Help
    60  
    61  ```
    62  NAME:
    63     micro new - Create a new micro service
    64  
    65  USAGE:
    66     micro new [command options] [arguments...]
    67  
    68  OPTIONS:
    69     --namespace "go.micro"	Namespace for the service e.g com.example
    70     --type "srv"			Type of service e.g api, srv, web
    71     --fqdn 			FQDN of service e.g com.example.srv.service (defaults to namespace.type.alias)
    72     --alias 			Alias is the short name used as part of combined name if specified
    73  ```