gogen

module
v1.129.3 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT

README

gogen

GitHub Release Go Reference Coverage Status Go Report Card OpenSSF Best Practices

Donate via PayPal Please consider supporting this project by making a donation via PayPal

gogen logo

This open-source project provides a collection of high-quality Go (Golang) packages.

Have you ever struggled with stitching together the small but essential pieces of infrastructure for a Go service, such as configuration loading, retries, health checks, logging, metrics, AWS integration, validation, and cache handling, only to end up copying the same helper functions from project to project?

That's exactly the problem gogen solves.

What makes it a good fit for Go teams

gogen is built for teams that want:

  • A consistent set of high-quality utilities across services
  • Reusable helper packages instead of ad hoc scripts
  • A modular import model, not a framework lock-in
  • A strong example-driven starting point via service
  • A Makefile workflow for testing, building, and scaffolding

It also includes a generator path: make project CONFIG=project.cfg can scaffold a new web service, giving you a fast start with sane defaults.

If you need a solid set of reusable Go packages for web services, infrastructure glue, or AWS integrations, gogen is worth a look.

The source code documentation is available at: https://pkg.go.dev/github.com/tecnickcom/gogen/


TOC


Packages

gogen offers a comprehensive collection of well-tested Go packages.
Each package adheres to common conventions and coding standards, making them easy to integrate into your projects.

  • awsopt - Utilities for configuring common AWS options with the aws-sdk-go-v2 library. [aws, configuration]
  • awssecretcache - Client for retrieving and caching secrets from AWS Secrets Manager. [aws, secrets, caching]
  • bootstrap - Helpers for application bootstrap and initialization. [bootstrap, initialization]
  • config - Utilities for configuration loading and management. [configuration]
  • countrycode - Functions for country code lookup and validation. [geolocation, validation]
  • countryphone - Phone number parsing and country association. [phone, geolocation, parsing]
  • decint - Helpers for parsing and formatting decimal integers. [numeric, formatting, parsing]
  • devlake - Client for the DevLake Webhook API. [webhook, api client]
  • dnscache - DNS resolution with caching support. [dns, caching, networking]
  • encode - Utilities for data encoding and serialization. [encoding, serialization]
  • encrypt - Helpers for encryption and decryption. [encryption, security]
  • enumbitmap - Encode and decode slices of enumeration strings as integer bitmap values. [enum, bitmap, encoding]
  • enumcache - Caching for enumeration values with bitmap support. [enum, caching]
  • enumdb - Helpers for storing and retrieving enumeration sets in databases. [enum, database]
  • errutil - Error utility functions, including error tracing. [error handling, utilities]
  • filter - Generic rule-based filtering for struct slices. [filtering, collections]
  • healthcheck - Health check endpoints and logic. [health, monitoring]
  • httpclient - HTTP client with enhanced features. [http, client]
  • httpretrier - HTTP request retry logic. [http, retry]
  • httpreverseproxy - HTTP reverse proxy implementation. [http, reverse proxy]
  • httpserver - HTTP server setup and management. [http, server]
  • httputil - HTTP utility functions. [http, utilities]
    • jsendx - Helpers for JSend-compliant responses. [http, response formatting]
  • ipify - IP address lookup using the ipify service. [ip lookup, networking, external service]
  • jirasrv - Client for Jira server APIs. [api client, integration]
  • jwt - JSON Web Token creation and validation. [jwt, authentication, security]
  • kafka - Kafka producer and consumer utilities. [kafka, messaging]
  • kafkacgo - Kafka integration using CGO bindings. [kafka, messaging, cgo]
  • logsrv - Default slog logger with zerolog handler. [logging, slog, zerolog]
  • logutil - General log utilities for log/slog integration. [logging, utilities]
  • maputil - Helpers for Go map manipulation. [map utilities, collections]
  • metrics - Metrics collection and reporting. [metrics, monitoring]
    • opentel - OpenTelemetry metrics exporter (includes tracing). [opentelemetry, metrics, tracing]
    • prometheus - Prometheus metrics exporter. [prometheus, metrics]
    • statsd - StatsD metrics exporter. [statsd, metrics]
  • mysqllock - Distributed locking using MySQL. [mysql, locking, distributed]
  • numtrie - Trie data structure for numeric keys with partial matching. [data structure, trie]
  • paging - Helpers for data pagination. [pagination, utilities]
  • passwordhash - Password hashing and verification. [password hashing, security]
  • passwordpwned - Password breach checking via HaveIBeenPwned. [password breach, security]
  • periodic - Periodic task scheduling. [scheduling, tasks]
  • phonekeypad - Phone keypad mapping utilities. [phone, mapping, utilities]
  • profiling - Application profiling tools. [profiling, performance]
  • random - Utilities for random data generation, including UUID. [random, utilities]
  • redact - Data redaction helpers. [redaction, privacy]
  • redis - Redis client and utilities. [redis, database, caching]
  • retrier - Retry logic for operations. [retry, utilities]
  • s3 - Helpers for AWS S3 integration. [aws, s3]
  • sfcache - Simple, in-memory, thread-safe, fixed-size, single-flight cache for expensive lookups. [caching, thread-safe, single-flight]
  • slack - Client for sending messages via the Slack API Webhook. [slack, webhook, messaging]
  • sleuth - Client for the Sleuth.io API. [api client, integration]
  • sliceutil - Utilities for slice manipulation. [slice utilities, collections]
  • sqlconn - Helpers for SQL database connections. [sql, database]
  • sqltransaction - SQL transaction management. [sql, transactions]
  • sqlutil - SQL utility functions. [sql, utilities]
  • sqlxtransaction - Helpers for SQLX transactions. [sqlx, transactions]
  • sqs - Utilities for AWS SQS (Simple Queue Service) integration. [aws, sqs, messaging]
  • stringkey - Create unique hash keys from multiple strings. [string keys, hashing]
  • stringmetric - String similarity and distance metrics. [text similarity, metrics]
  • strsplit - Utilities to split strings and Unicode text. [string utilities, text]
  • testutil - Utilities for testing. [testing, utilities]
  • threadsafe - Thread-safe data structures. [thread-safe, concurrency]
    • tsmap - Thread-safe map implementation. [thread-safe, map]
    • tsslice - Thread-safe slice implementation. [thread-safe, slice]
  • timeutil - Time and date utilities. [time, date utilities]
  • traceid - Trace ID generation and management. [tracing, ids]
  • typeutil - Type conversion and utility functions. [type conversion, utilities]
  • validator - Data validation utilities. [validation, utilities]
  • valkey - Wrapper client for interacting with valkey.io, an open-source in-memory data store. [data store, client]

Developers' Quick Start

To get started quickly with this project, follow these steps:

  1. Ensure you have the latest versions of Go and Python 3 installed (Python is required for additional tests).

  2. Clone the repository:

    git clone https://github.com/tecnickcom/gogen.git
    
  3. Navigate to the project directory:

    cd gogen
    
  4. Install dependencies and run all tests:

    make x
    

You are now ready to start developing with gogen!

This project includes a Makefile that simplifies testing and building on Linux-compatible systems. All artifacts and reports generated by the Makefile are stored in the target folder.

Alternatively, you can build the project inside a Docker container using:

make dbuild

This command uses the environment defined in resources/docker/Dockerfile.dev.

To view all available Makefile options, run:

make help

If you would like to contribute, please review the CONTRIBUTING.md guidelines.


Running all tests

Before committing your code, ensure it is properly formatted and passes all tests by running:

make x

Alternatively, you can build and test the project inside a Docker container with:

make dbuild

Web-Service project example

Refer to the examples/service directory for a sample web service built using this library.

To create a new project based on the example and the settings defined in project.cfg, run:

make project CONFIG=project.cfg

Directories

Path Synopsis
pkg
awsopt
Package awsopt provides functions to configure common AWS options for the official aws-sdk-go-v2 library.
Package awsopt provides functions to configure common AWS options for the official aws-sdk-go-v2 library.
awssecretcache
Package awssecretcache provides a simple client for retrieving and caching secrets from AWS Secrets Manager.
Package awssecretcache provides a simple client for retrieving and caching secrets from AWS Secrets Manager.
bootstrap
Package bootstrap provides a simple way to bootstrap an application with managed configuration, logging, metrics, application context, and shutdown signals.
Package bootstrap provides a simple way to bootstrap an application with managed configuration, logging, metrics, application context, and shutdown signals.
config
Package config handles the configuration of a program.
Package config handles the configuration of a program.
countrycode
Package countrycode provides fast, reusable access to ISO-3166 country metadata.
Package countrycode provides fast, reusable access to ISO-3166 country metadata.
countryphone
Package countryphone provides fast geographical lookup for phone number prefixes.
Package countryphone provides fast geographical lookup for phone number prefixes.
decint
Package decint provides utility functions to parse and represent decimal values as fixed-point integers with a defined precision.
Package decint provides utility functions to parse and represent decimal values as fixed-point integers with a defined precision.
devlake
Package devlake provides a basic client for the DevLake Webhook API.
Package devlake provides a basic client for the DevLake Webhook API.
dnscache
Package dnscache provides a local DNS cache that is safe for concurrent use, bounded in size, and uses single-flight request collapsing to avoid duplicate lookups.
Package dnscache provides a local DNS cache that is safe for concurrent use, bounded in size, and uses single-flight request collapsing to avoid duplicate lookups.
encode
Package encode provides a collection of helper functions for safe serialization and deserialization across system boundaries such as databases, queues, caches, and RPC payloads.
Package encode provides a collection of helper functions for safe serialization and deserialization across system boundaries such as databases, queues, caches, and RPC payloads.
encrypt
Package encrypt provides helpers for encrypting and decrypting data safely for transport and storage.
Package encrypt provides helpers for encrypting and decrypting data safely for transport and storage.
enumbitmap
Package enumbitmap provides helpers to encode and decode enumeration values as bitmaps.
Package enumbitmap provides helpers to encode and decode enumeration values as bitmaps.
enumcache
Package enumcache provides thread-safe storage and lookup for enumeration name and ID mappings.
Package enumcache provides thread-safe storage and lookup for enumeration name and ID mappings.
enumdb
Package enumdb loads enumeration sets from relational database tables into thread-safe enum caches.
Package enumdb loads enumeration sets from relational database tables into thread-safe enum caches.
errutil
Package errutil provides helpers for creating and inspecting errors in Go applications.
Package errutil provides helpers for creating and inspecting errors in Go applications.
filter
Package filter provides generic rule-based filtering capabilities for struct slices.
Package filter provides generic rule-based filtering capabilities for struct slices.
healthcheck
Package healthcheck provides a simple reusable framework for defining and collecting health checks for external services or application components.
Package healthcheck provides a simple reusable framework for defining and collecting health checks for external services or application components.
httpclient
Package httpclient provides a configurable, instrumented HTTP client for service communication.
Package httpclient provides a configurable, instrumented HTTP client for service communication.
httpretrier
Package httpretrier provides configurable retry logic for HTTP requests.
Package httpretrier provides configurable retry logic for HTTP requests.
httpreverseproxy
Package httpreverseproxy provides a reusable HTTP reverse proxy wrapper.
Package httpreverseproxy provides a reusable HTTP reverse proxy wrapper.
httpserver
Package httpserver defines a configurable default HTTP server with common routes and production-ready options.
Package httpserver defines a configurable default HTTP server with common routes and production-ready options.
httputil
Package httputil contains reusable HTTP request and response utility functions for Go services.
Package httputil contains reusable HTTP request and response utility functions for Go services.
httputil/jsendx
Package jsendx implements an extended JSend response model for HTTP APIs.
Package jsendx implements an extended JSend response model for HTTP APIs.
ipify
Package ipify allows to retrieve the public IP address of a service instance using the external ipify API (https://www.ipify.org/).
Package ipify allows to retrieve the public IP address of a service instance using the external ipify API (https://www.ipify.org/).
jirasrv
Package jirasrv provides a basic boilerplate client for the official Jira server API.
Package jirasrv provides a basic boilerplate client for the official Jira server API.
jwt
Package jwt provides simple wrapper functions for managing basic JWT Authentication with username/password credentials.
Package jwt provides simple wrapper functions for managing basic JWT Authentication with username/password credentials.
kafka
Package kafka provides a simple high-level API for producing and consuming Apache Kafka messages.
Package kafka provides a simple high-level API for producing and consuming Apache Kafka messages.
kafkacgo
Package kafkacgo provides a simple high-level API for producing and consuming Apache Kafka messages.
Package kafkacgo provides a simple high-level API for producing and consuming Apache Kafka messages.
logsrv
Package logsrv implements a zerolog-based logger compatible with the standard log/slog.
Package logsrv implements a zerolog-based logger compatible with the standard log/slog.
logutil
Package logutil provides general logging utilities for log/slog integration.
Package logutil provides general logging utilities for log/slog integration.
maputil
Package maputil provides a collection of utility functions for Go maps.
Package maputil provides a collection of utility functions for Go maps.
metrics
Package metrics defines a common interface for instrumenting applications and components to collect metrics.
Package metrics defines a common interface for instrumenting applications and components to collect metrics.
metrics/opentel
Package opentel implements the metrics interface for OpenTelemetry.
Package opentel implements the metrics interface for OpenTelemetry.
metrics/prometheus
Package prometheus implements the metrics interface for Prometheus.
Package prometheus implements the metrics interface for Prometheus.
metrics/statsd
Package statsd implements the metrics interface for StatsD.
Package statsd implements the metrics interface for StatsD.
mysqllock
Package mysqllock provides a distributed locking mechanism that leverages MySQL's internal functions.
Package mysqllock provides a distributed locking mechanism that leverages MySQL's internal functions.
numtrie
Package numtrie provides a numerical-indexed trie data structure.
Package numtrie provides a numerical-indexed trie data structure.
paging
Package paging provides utilities to handle pagination.
Package paging provides utilities to handle pagination.
passwordhash
Package passwordhash implements a practical model to create and verify a password hashes using a strong one-way hashing algorithm.
Package passwordhash implements a practical model to create and verify a password hashes using a strong one-way hashing algorithm.
passwordpwned
Package passwordpwned allows you to verify if a password has been pwned (compromised) in a data breach.
Package passwordpwned allows you to verify if a password has been pwned (compromised) in a data breach.
periodic
Package periodic provides a way to execute a given function periodically at a specified time interval.
Package periodic provides a way to execute a given function periodically at a specified time interval.
phonekeypad
Package phonekeypad provides functions to convert number strings to sequences of numbers corresponding to a standard phone keypad:
Package phonekeypad provides functions to convert number strings to sequences of numbers corresponding to a standard phone keypad:
profiling
Package profiling allows accessing the pprof profiling data via the HTTP interface of the Go program.
Package profiling allows accessing the pprof profiling data via the HTTP interface of the Go program.
random
Package random contains a collection of utility functions for generating random numbers and strings.
Package random contains a collection of utility functions for generating random numbers and strings.
redact
Package redact contains utility functions to obscure sensitive data.
Package redact contains utility functions to obscure sensitive data.
redis
Package redis provides a simple and basic wrapper client for interacting with Redis (https://redis.io), an in-memory data store.
Package redis provides a simple and basic wrapper client for interacting with Redis (https://redis.io), an in-memory data store.
retrier
Package retrier provides the ability to automatically repeat a user-defined function based on the error status.
Package retrier provides the ability to automatically repeat a user-defined function based on the error status.
s3
Package s3 provides a simple and basic wrapper client for interacting with an AWS S3 bucket.
Package s3 provides a simple and basic wrapper client for interacting with an AWS S3 bucket.
sfcache
Package sfcache provides a simple, local, thread-safe, fixed-size cache for expensive lookups with single-flight deduplication.
Package sfcache provides a simple, local, thread-safe, fixed-size cache for expensive lookups with single-flight deduplication.
slack
Package slack is a basic client for the official Slack API used to send messages via a Webhook.
Package slack is a basic client for the official Slack API used to send messages via a Webhook.
sleuth
Package sleuth provides a basic client for the official Sleuth.io API.
Package sleuth provides a basic client for the official Sleuth.io API.
sliceutil
Package sliceutil provides a collection of utility functions for Go slices.
Package sliceutil provides a collection of utility functions for Go slices.
sqlconn
Package sqlconn provides a simple way to connect to a SQL database and manage the connection.
Package sqlconn provides a simple way to connect to a SQL database and manage the connection.
sqltransaction
Package sqltransaction provides a simple way to execute a function inside an SQL transaction.
Package sqltransaction provides a simple way to execute a function inside an SQL transaction.
sqlutil
Package sqlutil provides SQL utility functions.
Package sqlutil provides SQL utility functions.
sqlxtransaction
Package sqlxtransaction provides a simple way to execute a function inside an SQLX transaction.
Package sqlxtransaction provides a simple way to execute a function inside an SQLX transaction.
sqs
Package sqs provides a simple and basic wrapper client for interacting with AWS SQS (Amazon Simple Queue Service).
Package sqs provides a simple and basic wrapper client for interacting with AWS SQS (Amazon Simple Queue Service).
stringkey
Package stringkey provides the ability to create a simple unique hash key from multiple strings.
Package stringkey provides the ability to create a simple unique hash key from multiple strings.
stringmetric
Package stringmetric provides functions to calculate string metrics, also known as string similarity metrics or string distance functions.
Package stringmetric provides functions to calculate string metrics, also known as string similarity metrics or string distance functions.
strsplit
Package strsplit contains utility functions to split Unicode strings.
Package strsplit contains utility functions to split Unicode strings.
testutil
Package testutil provides common testing utility functions.
Package testutil provides common testing utility functions.
threadsafe
Package threadsafe provides an interface for thread-safe functions that can be safely used across multiple goroutines.
Package threadsafe provides an interface for thread-safe functions that can be safely used across multiple goroutines.
threadsafe/tsmap
Package tsmap provides a collection of generic thread-safe Go map utility functions that can be safely used between multiple goroutines.
Package tsmap provides a collection of generic thread-safe Go map utility functions that can be safely used between multiple goroutines.
threadsafe/tsslice
Package tsslice provides a collection of generic thread-safe Go slice utility functions that can be safely used across multiple goroutines.
Package tsslice provides a collection of generic thread-safe Go slice utility functions that can be safely used across multiple goroutines.
timeutil
Package timeutil provides utility functions for working with time-related operations.
Package timeutil provides utility functions for working with time-related operations.
traceid
Package traceid allows storing and retrieving a Trace ID value associated with a context.Context and an HTTP request.
Package traceid allows storing and retrieving a Trace ID value associated with a context.Context and an HTTP request.
typeutil
Package typeutil contains a collection of type-related generic utility functions.
Package typeutil contains a collection of type-related generic utility functions.
uhex
Package uhex contains a collection of fast-encoding hex functions for unsigned integers.
Package uhex contains a collection of fast-encoding hex functions for unsigned integers.
validator
Package validator provides a simple and extensible field validation mechanism for structs and individual fields based on tags.
Package validator provides a simple and extensible field validation mechanism for structs and individual fields based on tags.
valkey
Package valkey provides a simple and basic wrapper client for interacting with Valkey (https://valkey.io), an open source in-memory data store.
Package valkey provides a simple and basic wrapper client for interacting with Valkey (https://valkey.io), an open source in-memory data store.

Jump to

Keyboard shortcuts

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