go-kratos /kratos
Your ultimate Go microservices framework for the cloud-native era.
★ 26,030⑂ 4,179👁 433⑃ 2,570● 1,284▤ 73
+0
Daily
+21
Weekly
+55
Monthly
26,030
stars
4,179
forks
433
watchers
2,570
prs
1,284
issues
73
releases
README
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
- API-first development with Protobuf and generated HTTP/gRPC code.
- Unified transport layer for HTTP and gRPC.
- Composable middleware for recovery, logging, validation, tracing, metrics, auth, and more.
- Pluggable registry, configuration, and encoding components.
- Standard-library log/slog based logging with OpenTelemetry extensions in contrib packages.
- Consistent metadata, errors, validation, OpenAPI, and code-generation workflows.
- A contrib ecosystem for optional integrations such as registries, config stores, middleware, encodings, and observability.
Installation
Requirements
- Go 1.25 or later
- protoc
- protoc-gen-go
Install the CLI
shell
go install github.com/go-kratos/kratos/cmd/kratos/v3@latest
kratos upgrade
Create a Service
shell
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:
shell
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
go
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
- Documentation
- Examples
- Project Layout
- v2 to v3 Migration Guide
- Community Contribution Guide
Development
shell
make test
make lint
Community
- Documentation
- WeChat Group
- Discord Group
- Discussions
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.
Acknowledgments
The following projects influenced Kratos design:
- go-kit/kit
- go-micro
- google/go-cloud
- go-zero
- beego
License
Kratos is open-sourced software licensed under the MIT license.Top issues
#969用户案例 | Who's using Kratos?47 comments · 2021-05-30#3868Kratos 命令行工具创建的模板与自身版本不匹配8 comments · 2026-08-07#3857在发送 grpc 请求时 header 无法支持数组5 comments · 2026-07-27#3815http server Bind errors bypass middleware chain (logging/tracing/recovery not executed)4 comments · 2026-04-20#3859kratos V3使用kratos-admin模板创建项目,启动web之后在用kratos run运行服务会一直报错3 comments · 2026-07-28#3861v3版本registry的nacos sdk v2.3.5, config的nacos sdk v1.1.62 comments · 2026-07-29#3854protobuf slice bounds out of range panic2 comments · 2026-07-19#3842kratos v3 `transport/grpc.NewClient` nil pointer panic2 comments · 2026-06-17
Discussions
#3763Audit logging in microservices0 comments · 2025-12-02#3750Discussion: How to handle path variables with different text names and json_name tags in EncodeURL1 comments · 2025-11-20#3726關於 grpc client 30 分鐘后會自動關閉地址更新的問題,1 comments · 2025-09-15#3518项目在windows环境下执行make api 会有提示格式错误1 comments · 2025-01-19#3488http.Server配置了http.Timeout选项,为什么请求接口的时间超过了设定的时间,不回返回请求超时错误1 comments · 2024-12-15#3453Goland波浪线错误提示1 comments · 2024-10-29#3423使用NewFilter日志不会输出该行的行号,怎么解决??1 comments · 2024-09-14#3419github.com/go-kratos/kratos/v2/metrics1 comments · 2024-09-12
Latest release
v3.0.0 v3.0.0 2026-06-26Breaking Changes - break: update kratos modules to v3 (3822) New Features - feat(errors): add standard library errors wrappers (3844) - feat(transport/http): add read/write deadline control to ServerStream (3843) - feat(protoc-gen-go-http): support google.api.HttpBody response (3839) - feat(config): add generic config Get support (3778) - feat(middleware/auth/jwt): add WithParserOptions to allow configuring… (3803) - feat: support pre condition failed code mapping (3795) - feat(cmd): add --repo flag to kratos new command (3789) - feat(errors): add TooManyRequests error type (3787)