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

Proposal: Default env tag

mymmrac opened this issue · comments

Hello, I propose to use filed name (to uppercase & to snake case) as default env tag if it's not specified

For example, this struct:

type A struct {
    SomeText string
}

will be parsed the same as this:

type A struct {
    SomeText string `env:"SOME_TEXT"`
}

New option can be introduced that will enable this functionality in order not to make braking change.

This will allow more convenient API for smaller application that do not critically depend on env names.

WDYT?

interesting idea, will try to build a PoC

Yep, something like that will work perfectly