Sting of the Viper

I was playing around writing a simple command-line tool and I struggled to make flags work together with environment variables. I choose spf13/cobra since is the one that we are currently using at work, it’s widely adopted and well documented, but the solution to this problem is not simple as the one offered by urfave/cli, where you just need to set the EnvVars field of your Flag &cli.StringFlag{ EnvVars: []string{"MY_VAR"}, } Unfortunately with cobra is not that easy and googling around I’ve stumbled on this awesome blog post by @carolynvs:...

April 21, 2022