Skip to content

Releases: digvijay-tech/envconfig

Release v1.0.0

25 Oct 17:19

Choose a tag to compare

Features

  • Struct-based configuration: Load .env files into Go structs using envconfig struct tags
  • Type support: Supports string, int/uint variants, float32, float64, and bool types
  • Environment loading: Automatically loads parsed variables into os.Getenv() for global access
  • Flexible file handling: Customisable .env file path and name (defaults to ./.env)
  • Robust parsing: Handles comments, empty lines, quoted values, and validates environment variable keys

Usage

type Config struct {
    Name string `envconfig:"NAME"`
    Port int    `envconfig:"PORT"`
}

opts := envconfig.EnvOptions[Config]{
    Schema: &Config{},
}
config, err := envconfig.Configure(opts)

Installation

go get github.com/digvijay-tech/envconfig@v1.0.0

This is the initial release of envconfig, offering a simple and type-safe approach to effortlessly manage environment-based configuration in Go applications.