Skip to main content

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.

go env -w GO111MODULE=on

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

Installation#

# install kratos CLI toolgo get -u github.com/go-kratos/kratos/cmd/kratos/v2@latest

Project Creation#

# create project's layoutkratos new helloworld
cd helloworld# pull dependenciesgo mod download# generate proto templatekratos proto add api/helloworld/helloworld.proto# generate proto codekratos proto client api/helloworld/helloworld.proto# generate server templatekratos proto server api/helloworld/helloworld.proto -t internal/service

Compilation and Running#

# generate all codes of proto and wire etc.go generate ./...
# run the applicationkratos run

Try it out#

curl 'http://127.0.0.1:8000/helloworld/kratos'
The response should be{  "message": "Hello kratos"}

Project Layout#

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