go-kit

module
v0.0.0-...-081568e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2025 License: MIT

README

ExoPulse Go-Kit

A comprehensive toolkit of Go utilities and helpers designed to simplify common tasks in Go applications.

Overview

ExoPulse Go-Kit is a collection of lightweight, reusable Go packages that provide solutions for common programming tasks. The toolkit is designed with simplicity, performance, and modern Go practices in mind.

Go codecov

Features

  • Environment Configuration (envconf): Parse environment variables into Go structs with extended boolean flag support and custom formats.
  • Host Utilities (hostutil): Tools for working with host-related functionality.
  • HTTP Server (httpd): Utilities for HTTP server implementation.
  • REST Helpers (rest):
    • reqlog: Request logging middleware and utilities for Gin framework
    • router: Simplified router implementation for Gin-based applications
  • Structured Logging (slog): Zerolog-based structured logging with context support.
  • String Utilities (strutil): Helper functions for string manipulation.
  • Time Extensions (timex): Extended time functionality and duration parsing.

Installation

go get github.com/exopulse/go-kit

Usage Examples

Environment Configuration
package main

import (
    "fmt"
    "github.com/exopulse/go-kit/envconf"
    "github.com/exopulse/go-kit/timex"
)

type Config struct {
    Debug    bool          `env:"DEBUG"`
    Timeout  timex.Duration `env:"TIMEOUT"`
    LogLevel string        `env:"LOG_LEVEL" envDefault:"info"`
}

func main() {
    var cfg Config
    if err := envconf.Parse(&cfg); err != nil {
        panic(err)
    }
    
    fmt.Printf("Config: %+v\n", cfg)
}
Request Logging
package main

import (
    "github.com/exopulse/go-kit/rest/reqlog"
    "github.com/exopulse/go-kit/slog"
    "github.com/gin-gonic/gin"
)

func main() {
    r := gin.New()
    
    // Add request logger middleware
    r.Use(func(c *gin.Context) {
        logger := slog.Global
        reqlog.SetLogger(c, logger)
        c.Next()
    })
    
    r.GET("/example", func(c *gin.Context) {
        // Get logger from context
        logger := reqlog.RequestLogger(c)
        logger.Info().Msg("Processing request")
        
        c.JSON(200, gin.H{"status": "ok"})
    })
    
    r.Run(":8080")
}

Requirements

  • Go 1.24 or higher

License

This project is licensed under the MIT License - see the LICENSE file for details.

Directories

Path Synopsis
Package env provides functionality for loading environment variables.
Package env provides functionality for loading environment variables.
Package envconf parses environment variables into a custom structs.
Package envconf parses environment variables into a custom structs.
Package hostutil implements host address related utilities.
Package hostutil implements host address related utilities.
Package httpd implements an HTTP server.
Package httpd implements an HTTP server.
rest
reqlog
Package reqlog provides utilities for working with request context.
Package reqlog provides utilities for working with request context.
router
Package router provides the REST router for the identity service.
Package router provides the REST router for the identity service.
Package slog implements a structured logger.
Package slog implements a structured logger.
Package strutil provides some common string related utilities not available in standard packages.
Package strutil provides some common string related utilities not available in standard packages.
Package timex implements Duration type capable of parsing duration unit larger than one hour.
Package timex implements Duration type capable of parsing duration unit larger than one hour.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL