Skip to content

Just a collection of useful Go utilities for various tasks

License

Notifications You must be signed in to change notification settings

OliverSchlueter/goutils

Repository files navigation

GoUtils

Just a collection of useful Go utilities for various tasks.

Features

  • sloki: structured logger that supports multiple output formats
  • broker: an abstraction layer for message brokers (e.g. for Nats)
  • middleware: a collection of commonly used middlewares
  • featureflags: a simple feature flag implementation
  • containers: connect to common containers (e.g. MongoDB, Redis, Nats)
  • cloudevents: utilities for working with CloudEvents (1.0.2)
  • problem: a structured error handling package (RFC 7807 compliant)
  • healthcheck: a health check handler for HTTP servers
  • idgen: ID generation
  • ratelimit: rate limiting
  • sitemapgen: sitemap generation for websites
  • badgegen: badge generation for README files and websites

Installation

go get github.com/OliverSchlueter/goutils

sloki

lokiService := sloki.NewService(sloki.Configuration{
    URL:          "http://localhost:3100/loki/api/v1/push",
    Service:      "my-service",
    ConsoleLevel: slog.LevelDebug,
    LokiLevel:    slog.LevelInfo,
    EnableLoki:   true,
})
slog.SetDefault(slog.New(lokiService))

slog.Info("Hello, world!", "key", "value")

The field limits_config.allow_structured_metadata in the loki configuration must be set to true to allow structured metadata.