Your ultimate Go microservices framework for the cloud-native era.
Your ultimate Go microservices framework for the cloud-native era.
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.
log/slog based logging with OpenTelemetry extensions in contrib packages.go install github.com/go-kratos/kratos/cmd/kratos/v3@latest
kratos upgradekratos new helloworld
cd helloworld
go mod tidy
kratos runVisit 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 runpackage 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)
}
}Kratos v3 reduces core dependencies and makes previously implicit behavior explicit. Review the v2 to v3 migration guide before upgrading production services.
make test
make lintIf you discover a security vulnerability in Kratos, please contact [email protected]. Security reports are handled privately before disclosure.
Thank you for contributing to Kratos. The contribution guide is available in the Kratos documentation.
The following projects influenced Kratos design:
Kratos is open-sourced software licensed under the MIT license.
middleware/logging: duplicate error string recorded in `error` & `stack`, and all non-nil errors hardcoded to LevelError
[Vulnerability] GO-2026-5471
Config map-merge keeps both proto field spellings; Scan fails with duplicate field
Config map-merge keeps both proto field spellings; Scan fails with duplicate field
go-kratos.dev的文档该更新了
Boolean config fields cannot be overridden from the environment
protobuf slice bounds out of range panic
http server Bind errors bypass middleware chain (logging/tracing/recovery not executed)
Kratos 命令行工具创建的模板与自身版本不匹配
middleware/metadata: non-ASCII values break gRPC calls, header values should be percent-encoded