A standard library for microservices.


License
MIT
Install
go get github.com/dreamsxin/go-kit/v2

Documentation

go-kit

Go Version License

English | 简体中文

go-kit is a component-oriented Go service framework built around one request path:

Service -> Endpoint -> Transport

Use only the packages you need, or let microgen generate a complete, runnable service from a Go interface, Protobuf contract, or database schema.

The maintained product line is the independent v2/ module. Start with the v2 README, use the documentation index to choose a task, or open the complete book.

Quick Example

svc, err := kit.NewHTTP(":8080", kit.WithRequestID())
if err != nil {
	log.Fatal(err)
}
kit.HandleJSONTyped(svc, "POST /greet", func(
	_ context.Context, req GreetRequest,
) (GreetResponse, error) {
	return GreetResponse{Message: "Hello, " + req.Name + "!"}, nil
})
host, err := kit.NewHost(kit.WithLifecycle(svc))
if err != nil {
	log.Fatal(err)
}
// host.Run(ctx) serves with health checks, graceful shutdown, and strict JSON

Full walkthrough: getting started.

Components

Component What it provides Guide
endpoint typed endpoints, middleware (validation, timeout, recovery, circuit breaker, rate limit, fallback, bulkhead, tracing) guide
apperror transport-neutral error classification mapped by every transport guide
transport/http JSON server/client, SSE, multipart, pagination, response envelopes guide
kit service assembly, health checks, lifecycle guide
sd service discovery, balancing, retry guide
interaction AI tool runtime and MCP Streamable HTTP guide
security transport-neutral authentication subjects and endpoint enforcement guide
security/http CORS, CSRF, security headers, IP policy guide
observability slog, OpenTelemetry, correlation, and bounded telemetry guide
microgen project generation with Go/TS SDKs and OpenAPI guide

Documentation

  • Book: the complete guide — topic chapters and complete tutorials (getting started, CRUD, generation, authentication, MCP)
  • Documentation index: choose a document by task
  • Custom transports: custom HTTP codecs and non-HTTP protocol adapters
  • Observability: logs, metrics, traces, and request correlation
  • Examples: runnable services for every component
  • Production: deployment, alerting, background jobs
  • Changelog

Current Release

The maintained product line is the independent v2 module under v2/:

go get github.com/dreamsxin/go-kit/v2@latest
go install github.com/dreamsxin/go-kit/v2/cmd/microgen@latest

v2.8.0 is the current architecture release, and it ships as a single module: one require, one tag (see CHANGELOG).

Development

go -C v2 test ./...
go -C v2 vet ./...

Before a release candidate, run the cross-module and standalone gates:

go -C v2/tools run ./releaseverify -root .. -suites test,standalone,vet,tidy,race

License

MIT. See LICENSE.txt.