A lightweight, framework-agnostic Go module of shared utilities for building RESTful APIs. Extracted from production services at porygon-labs.
| Package | Purpose | External deps |
|---|---|---|
logger |
Global slog.Logger with Init/Default and convenience wrappers |
None (stdlib) |
response |
Consistent JSON API envelope ({ meta, data }) via http.ResponseWriter |
None (stdlib) |
hash |
Sqids-based integer ID obfuscation with canonical verification | sqids-go |
telemetry |
OTel OTLP gRPC tracer setup + auto-named span helper | OTel SDK |
config |
Generic Load[T any]() — .env + env vars into your struct |
caarlos0/env, godotenv |
go get github.com/porygon-labs/go-kitimport (
"github.com/porygon-labs/go-kit/logger"
"github.com/porygon-labs/go-kit/response"
"github.com/porygon-labs/go-kit/hash"
"github.com/porygon-labs/go-kit/telemetry"
)Import only what you need. Unused packages don't pull their dependencies into your go.mod.
logger.Init(logger.New("debug", "json"))
logger.Info("server started", "port", 8080)
logger.Error("something broke", "error", err)func handler(w http.ResponseWriter, r *http.Request) {
response.OK(w, map[string]string{"hello": "world"})
// → {"meta":{"is_success":true,"message":"OK"},"data":{"hello":"world"}}
}Works with any framework that exposes http.ResponseWriter — Echo, Gin, Chi, or plain net/http.
h, _ := hash.NewHash("abcdefghijklmnopqrstuvwxyz0123456789")
encoded, _ := h.Encode(42) // → "someHash"
ids, _ := h.Decode(encoded) // → []int64{42}shutdown, _ := telemetry.Init(ctx, "my-service", "otel-collector:4317")
defer shutdown(ctx)
// Spans auto-named by caller function:
ctx, end := telemetry.StartSpan(ctx)
defer end()go-kit targets the standard library. Tested with:
- Echo v5 — pass
c.Response()ashttp.ResponseWriter - Gin — pass
c.Writerashttp.ResponseWriter - Chi / net/http — pass
wdirectly
MIT — see LICENSE.