Our great sponsors
- SonarLint - Clean code begins in your IDE with SonarLint
- InfluxDB - Access the most powerful time series database as a service
- ONLYOFFICE ONLYOFFICE Docs — document collaboration in your environment
-
Personally I used https://github.com/urfave/cli for CLI a lot but ended up migrating few project to cobra just because while way to use it was pretty aisine and annoying it ended up better at parsing said CLI (urfave/cli insist on positional arguments which don't work well for some cases)
-
-
SonarLint
Clean code begins in your IDE with SonarLint. Up your coding game and discover issues early. SonarLint is a free plugin that helps you find & fix bugs and security issues from the moment you start writing code. Install from your favorite IDE marketplace today.
-
-
For all my commandline parsing and config loading needs I use kong. In contrast to Viper and Cobra it has almost no dependencies (while viper and cobra pull in half a jungle).
-
Have a look at https://github.com/peterbourgon/ff
-
check this package: https://github.com/ilyakaznacheev/cleanenv
-
conf
Package conf provides support for using environmental variables and command line arguments for configuration. (by ardanlabs)
-
InfluxDB
Access the most powerful time series database as a service. Ingest, store, & analyze all types of time series data in a fully-managed, purpose-built database. Keep data forever with low-cost storage and superior data compression.
-
Pretty much all of our services and pkgs use https://github.com/kelseyhightower/envconfig. It’s dead simple, gets out of your way, and is battle tested
-
Shameless self-promotion: I encountered the same pain points and put together a small library to tie together multiple configuration sources. As I still really like cobra it is intended to be used with pflags.
-
Self promo: it won’t help with the config file side of things but should elegantly cover the flags and environment variables: https://github.com/cavaliergopher/xflags.
-
For config I ended up making wrapper for YAML parser that did the "pick a config from list list" and "generate default config" features. But my config needs are not that big