go-toolkit

module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT

README

Go Toolkit

Go Reference CI Go Report Card License Go Version

A collection of production-grade utility packages for building REST API services in Go. Go Toolkit provides reusable, well-tested building blocks for common backend tasks — from error handling and configuration management to database connections and JWT authentication — so you can focus on your application logic instead of reinventing infrastructure.

Installation

# Core module (lightweight utilities)
go get github.com/alpardfm/go-toolkit

# Heavy module (database, AWS, logging, JWT, etc.)
go get github.com/alpardfm/go-toolkit/heavy

Requires Go 1.21 or later.

Module Structure

The toolkit is split into two Go modules to minimize dependency bloat:

Module Import Path Description
Core github.com/alpardfm/go-toolkit Lightweight utilities with minimal dependencies (operator, convert, errors, codes, concurrency, hash, encrypt, random, format, files, validation, distance, appcontext, language, header, sorter, parser)
Heavy github.com/alpardfm/go-toolkit/heavy Packages requiring large external dependencies (configbuilder, configreader, nosql, sql, smtp, log, tokens, query)

If you only need lightweight utilities like type conversion, error handling, or hashing, import the core module — your project won't pull in AWS SDK, MongoDB driver, or database drivers.

For details on which dependencies each package requires, see DEPENDENCIES.md. If you're migrating from the single-module layout, see MIGRATION.md for updated import paths.

Package Overview

Package Description GoDoc
appcontext Request-scoped context value management GoDoc
codes Error code registry with bilingual messages (EN/ID) GoDoc
concurrency Goroutine worker pool with configurable max workers GoDoc
configbuilder AWS SSM parameter store config generator GoDoc
configreader Viper-based configuration file reader GoDoc
convert Type conversion utilities (int64, float64, string, struct copy) GoDoc
distance Geographic distance calculation GoDoc
encrypt AES-256-GCM encryption/decryption GoDoc
errors Stacktrace-enriched error handling with error codes GoDoc
files File system utilities GoDoc
format Date and string formatting helpers GoDoc
hash Password hashing (argon2, bcrypt, sha256) GoDoc
header HTTP header extraction utilities GoDoc
language Bilingual text support (EN/ID) GoDoc
log Structured logging via zerolog GoDoc
nosql MongoDB client wrapper GoDoc
operator Ternary operator and generic utilities GoDoc
parser JSON marshaling/unmarshaling interface GoDoc
query SQL/GQL query builder from struct tags GoDoc
random Random value generation (int, UUID-based) GoDoc
smtp Email sending via gomail GoDoc
sorter Generic sorting with custom comparators GoDoc
sql Database connection management (leader/follower) GoDoc
tokens JWT token creation and validation GoDoc
validation Input validation utilities (email, etc.) GoDoc

Breaking Changes (v1.0.0)

The following breaking changes were introduced in v1.0.0 to improve safety and correctness:

  • configbuilder: Init() now returns (Interface, error) instead of Interface
  • configreader: Init() now returns (Interface, error) instead of Interface
  • sql: Init() now returns (Interface, error) instead of Interface
  • concurrency: Do() now returns a multi-error (via errors.Join) containing all goroutine errors
  • tokens: JWT library migrated from dgrijalva/jwt-go/v4 to golang-jwt/jwt/v5

See CHANGELOG.md for full details.

Versioning

This project follows Semantic Versioning 2.0.0. Releases are tagged using annotated git tags in the format vMAJOR.MINOR.PATCH.

  • MAJOR version increments indicate breaking API changes
  • MINOR version increments add functionality in a backward-compatible manner
  • PATCH version increments include backward-compatible bug fixes

See CHANGELOG.md for a history of changes by version.

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for development setup, coding standards, and the pull request process.

License

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

Directories

Path Synopsis
Package codes defines a registry of numeric error and status codes used throughout the toolkit.
Package codes defines a registry of numeric error and status codes used throughout the toolkit.
Package concurrency provides a goroutine worker pool that executes functions in batches with a configurable maximum number of concurrent workers.
Package concurrency provides a goroutine worker pool that executes functions in batches with a configurable maximum number of concurrent workers.
Package convert provides type conversion utilities for common Go types including int64, float64, string, and struct-to-struct copying.
Package convert provides type conversion utilities for common Go types including int64, float64, string, and struct-to-struct copying.
Package distance provides geographic distance calculation between two coordinates using the Haversine formula.
Package distance provides geographic distance calculation between two coordinates using the Haversine formula.
Package encrypt provides AES-256-GCM authenticated encryption and decryption.
Package encrypt provides AES-256-GCM authenticated encryption and decryption.
Package errors provides stacktrace-enriched error handling with error codes.
Package errors provides stacktrace-enriched error handling with error codes.
Package hash provides password hashing and verification using industry-standard algorithms: Argon2id, bcrypt, and SHA-256 (with optional HMAC key).
Package hash provides password hashing and verification using industry-standard algorithms: Argon2id, bcrypt, and SHA-256 (with optional HMAC key).
Package random provides cryptographically secure random value generation.
Package random provides cryptographically secure random value generation.
Package validation provides input validation utilities for common formats such as email addresses.
Package validation provides input validation utilities for common formats such as email addresses.

Jump to

Keyboard shortcuts

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