ardanlabs/conf

Question: Using env vars without prefix

pantelis-karamolegkos opened this issue · 3 comments

Sorry in advance for opening a question as an issue, could not find a relevant community to direct this.

How can we use the env vars without prefix?

When I pass the empty string as prefix:

if err := conf.Parse(os.Args[1:], "", &cfg); 

I get a leading underscore in the env vars generated

  --web-service-port/$_SERVICE_PORT                    <int>     (default: 98765)

This was previously defined in a cfg struct as follows

		Web struct {
			ServicePort int `conf:"default:98765,env:SERVICE_PORT"`
		}

I can make a code change to support this is an empty string is provided.

There is now version v1.4.0 that handles what you need.

💯 cool! Many thanks Bill.