Quick Start

Version

The version of kratos must be v2.0.0 or above.

Environment Requirements

These environments and tools must be installed properly.

The GO111MODULE should be enabled.

  1. go env -w GO111MODULE=on

If you faced with network problem (especially you are in China Mainland), please setup GOPROXY

Install Kratos tool

You can do it either way.

1. go install installation

  1. go install github.com/go-kratos/kratos/cmd/kratos/v2@latest

2. Source code compilation and installation

  1. git clone https://github.com/go-kratos/kratos
  2. cd kratos
  3. make install

Project Creation

  1. # create project's layout
  2. kratos new helloworld
  3. cd helloworld
  4. # pull dependencies
  5. go mod download

Compilation and Running

  1. # generate all codes of proto and wire etc.
  2. go generate ./...
  3. # run the application
  4. kratos run

Try it out

  1. curl 'http://127.0.0.1:8000/helloworld/kratos'
  2. The response should be
  3. {
  4. "message": "Hello kratos"
  5. }

Project Layout

Kratos CLI always pull the layout project from GitHub for project creation. The layout project is: