kratos README

The project's README from github.com/go-kratos/kratos. As one markdown file: README.md.

Build Status GoDoc DeepWiki codeCov Go Report Card License Awesome Go Discord

go-kratos%2Fkratos | Trendshift Go Kratos - A Go framework for microservices. | Product Hunt

Translations: English | 简体中文

Kratos

Kratos is a lightweight Go framework for building cloud-native microservices. It provides small, explicit APIs for transport, middleware, registry, configuration, logging, encoding, and code generation so applications can focus on business logic.

Features

Installation

Requirements

Install the CLI

go install github.com/go-kratos/kratos/cmd/kratos/v3@latest
kratos upgrade

Create a Service

kratos new helloworld
cd helloworld
go mod tidy
kratos run

Visit http://localhost:8000/helloworld/kratos after the service starts.

For a fuller generated service flow:

kratos proto add api/helloworld/helloworld.proto
kratos proto client api/helloworld/helloworld.proto
kratos proto server api/helloworld/helloworld.proto -t internal/service
go generate ./...
kratos run

Usage Example

package main

import (
	"github.com/go-kratos/kratos/v3"
	"github.com/go-kratos/kratos/v3/transport/grpc"
	"github.com/go-kratos/kratos/v3/transport/http"
)

func main() {
	httpSrv := http.NewServer(http.Address(":8000"))
	grpcSrv := grpc.NewServer(grpc.Address(":9000"))

	app := kratos.New(
		kratos.Name("helloworld"),
		kratos.Version("v1.0.0"),
		kratos.Server(httpSrv, grpcSrv),
	)
	if err := app.Run(); err != nil {
		panic(err)
	}
}

v3 Migration

Kratos v3 reduces core dependencies and makes previously implicit behavior explicit. Review the v2 to v3 migration guide before upgrading production services.

Further Reading

Development

make test
make lint

Community

Security

If you discover a security vulnerability in Kratos, please contact [email protected]. Security reports are handled privately before disclosure.

Contributors

Thank you for contributing to Kratos. The contribution guide is available in the Kratos documentation.

Kratos contributors

Acknowledgments

The following projects influenced Kratos design:

License

Kratos is open-sourced software licensed under the MIT license.

kratos (go-kratos/kratos)

rpc
Searching Database…

26K ·GitHub
What is this?Kratos is a lightweight Go framework for building cloud-native microservices, with small, explicit APIs so your code can focus on business logic instead of plumbing.
Is this a framework I build my whole service on, or a loose set of helper libraries?It's a full framework: the Kratos CLI scaffolds a service, and you build on its explicit APIs for transport, middleware, registry, configuration, logging, encoding and code generation.
How do I get a first service up and running?Install the Kratos CLI, then create a service with it — once the generated service starts you visit a local URL to check it, and the docs cover the fuller generated service flow.
What do I need installed before I can scaffold anything?Go 1.25 or later, plus protoc and protoc-gen-go for generating code from Protobuf definitions.
Anything to watch out for if I'm upgrading an existing Kratos service?Moving from v2 to v3 isn't a drop-in: v3 reduces core dependencies and makes previously implicit behavior explicit, so the README says to review the migration guide before upgrading production services.
What does Kratos handle out of the box so I don't have to wire it myself?A unified transport layer for HTTP and gRPC, composable middleware for recovery, logging, validation, tracing, metrics and auth, slog-based logging with OpenTelemetry extensions in contrib, and consistent metadata, errors, validation and OpenAPI workflows.
How does the API-first workflow look in practice?You define your API in Protobuf and Kratos generates the HTTP and gRPC code from it, so the contract drives the service implementation.
What if the core lacks a registry, config store or middleware I need?Registry, configuration and encoding components are pluggable, and a contrib ecosystem adds optional integrations for registries, config stores, middleware, encodings and observability.
Which projects influenced Kratos's design?The README credits go-kit/kit, go-micro, google/go-cloud, go-zero and beego as design influences.
Creator
go-kratos
Size
9.8 MB
Stars
26K
Age
7y
Commits · 90 Days