caarlos0 / env

A simple, zero-dependencies library to parse environment variables into structs

Home Page:https://pkg.go.dev/github.com/caarlos0/env/v11

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add functionality to fetch a slice of used environment variables in config

saturn4er opened this issue · comments

In some cases, it's useful to be able to retrieve all the possible configurations of an application. To address this, it would be great to have a feature that allows fetching a slice of used environment variables in the config.

This feature will enable the ability to print a list of available configs for an application or to create a .env file template.

I propose adding the following struct, which represents an environment parameter:

type EnvParameter struct{
   EnvVariable   string
   DefaultValue  string
   Required      bool
   NotEmpty      bool
   Unset         bool
   ReadFromFile  bool
}

The implementation should provide a function to collect all the environment variables used in the config and return a slice of EnvParameter structs, containing the necessary details about each variable.