awesome-repositories.com
Blog
MCP
awesome-repositories.com

Discover the best open-source repositories with AI-powered search.

ExploreCurated searchesOpen-source alternativesSelf-hosted softwareBlogSitemap
ProjectMCP serverAboutHow we rankPress
LegalPrivacyTerms
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
caarlos0 avatar

caarlos0/env

0
View on GitHub↗
6,004 stars·273 forks·Go·mit·24 viewspkg.go.dev/github.com/caarlos0/env/v11↗

Env

env is a Go library that reads environment variables and populates the fields of a Go struct according to tag directives. It uses reflection to iterate over struct types and tags at runtime, mapping environment variable names to struct fields and applying parsing behavior defined in struct tags.

The library supports required field validation, returning errors when marked fields are missing or empty after parsing. It also provides default value fallback from struct tags when environment variables are not set, environment variable expansion that recursively substitutes references within values, and file content injection that reads file contents from paths specified in environment variables and assigns them directly to struct fields. Users can register custom parser functions to convert strings into arbitrary Go types during unmarshaling.

The project includes an API integration for fetching module and package details, listing module versions and packages, and searching packages and symbols. It also provides pagination support for API responses and rate limiting to 40 queries per second per IP.

Features

  • Environment Variable-Based Configuration - Reads environment variables and populates the fields of a Go struct according to tag directives.
  • Environment Variable Validation - Marks a field as required or non-empty, causing an error if the variable is missing or blank.
  • Custom Parser Registries - Registers custom functions to parse environment variable strings into any Go type.
  • Variable Substitutions - Substitutes embedded environment variable references within a variable's value during parsing.
  • Environment Variable Substitution - Recursively substitutes ${VAR} or $VAR references within environment variable values before assignment.
  • Schema Default Values - Applies fallback values from struct tags when environment variables are missing or empty.
  • Struct Tags - Uses Go struct field tags to map environment variable names and configure parsing behavior for each field.
  • Reflection-Based Unmarshallers - Populates struct fields by iterating over types and tags at runtime using Go's reflect package.
  • Required Field Enforcement - Checks for missing or empty environment variables after parsing and returns errors for required fields.
  • Custom Parser Registries - Provides a registry for custom parser functions that convert environment variable strings to arbitrary Go types.
  • Environment Variable File Injectors - Reads file contents from paths specified in environment variables and assigns them directly to struct fields.
  • File-Based Loading - Reads the content of a file whose path is given by an environment variable and assigns it to the struct field.
  • Configuration Management - Parses environment variables into structs.
  • Configuration Management - Listed in the “Configuration Management” section of the Awesome Go awesome list.
  • Configuration Management - Environment variable parser for structs.

Star history

Star history chart for caarlos0/envStar history chart for caarlos0/env

How this analysis was created: This summary and feature list are AI-generated from collected project material and can contain mistakes. Stars, license and language are imported from GitHub. Inclusion does not mean that we have tested or audited this project. Check the source documentation for any feature you depend on. Learn more on our About page.

AI search

Explore more awesome repositories

Describe what you need in plain English — the AI ranks thousands of curated open-source projects by relevance.

Start searching with AI

Projects sharing features with Env

These projects share indexed features with Env. Shared tags can include platform or build tooling; verify the primary use case before treating a result as a replacement.
  • googleapis/google-api-go-clientgoogleapis avatar

    googleapis/google-api-go-client

    4,395View on GitHub↗

    The Google API Go Client Library is a collection of auto-generated Go packages designed to facilitate authenticated requests to Google services via HTTP and gRPC. It serves as an API request and response manager that converts API discovery documents into typed code to provide a consistent interface for interacting with various services. The library includes a dedicated OAuth 2.0 authentication client used to manage token lifecycles, handle service account credentials, and perform authorization flows. It supports identity impersonation, allowing a security context to assume the identity of a t

    Gogo
    View on GitHub↗4,395
  • kelseyhightower/envconfigkelseyhightower avatar

    kelseyhightower/envconfig

    5,404View on GitHub↗

    envconfig is a Go configuration decoder and environment variable mapper that deserializes environment variables into structured Go data types. It provides tools for validating mandatory fields and ensuring application configuration adheres to the external configuration patterns of twelve-factor app compliance. The library features a help generator that creates formatted usage text based on struct definitions to describe expected environment variables. It also includes a validation tool capable of detecting unused environment variables that match a specific prefix but do not correspond to any

    Go
    View on GitHub↗5,404
  • knadh/koanfknadh avatar

    knadh/koanf

    3,871View on GitHub↗

    koanf is a configuration management library for Go designed to load, merge, and unmarshal application settings from multiple sources into structured objects. It functions as a multi-source config loader that aggregates data from environment variables, files, and remote providers into a single unified map. The system utilizes a pluggable architecture for parsing and data abstraction, allowing it to transform bytes from formats such as JSON, YAML, and TOML into nested maps. It supports dynamic configuration watching to monitor external sources and trigger automatic reloads when settings change.

    Goconfigconfig-loaderconfiguration
    View on GitHub↗3,871
  • vlucas/phpdotenvvlucas avatar

    vlucas/phpdotenv

    13,536View on GitHub↗

    phpdotenv is a PHP environment variable loader and configuration parser. It reads key-value pairs from files and populates them into PHP system environment variables and global arrays to avoid hardcoding sensitive settings in code. The project includes a configuration variable interpolator to resolve nested references and variables within environment files. It also provides an environment variable validator to ensure required variables exist and match specific data types or values. The system covers application secret management, multi-environment deployment, and the parsing of raw configura

    PHPconfigurationdotenvenvironment
    View on GitHub↗13,536
Compare all 30 related projects→

Frequently asked questions

What does caarlos0/env do?

env is a Go library that reads environment variables and populates the fields of a Go struct according to tag directives. It uses reflection to iterate over struct types and tags at runtime, mapping environment variable names to struct fields and applying parsing behavior defined in struct tags.

What are the main features of caarlos0/env?

The main features of caarlos0/env are: Environment Variable-Based Configuration, Environment Variable Validation, Custom Parser Registries, Variable Substitutions, Environment Variable Substitution, Schema Default Values, Struct Tags, Reflection-Based Unmarshallers.

Which projects share features with caarlos0/env?

Projects with overlapping indexed features include: googleapis/google-api-go-client — The Google API Go Client Library is a collection of auto-generated Go packages designed to facilitate authenticated… kelseyhightower/envconfig — envconfig is a Go configuration decoder and environment variable mapper that deserializes environment variables into… knadh/koanf — koanf is a configuration management library for Go designed to load, merge, and unmarshal application settings from… vlucas/phpdotenv — phpdotenv is a PHP environment variable loader and configuration parser. It reads key-value pairs from files and… theskumar/python-dotenv — python-dotenv is a library and command line interface for managing environment variables in Python applications. It… alecthomas/kong — Kong is a declarative command line interface framework and parser for Go. It maps flags and positional arguments…