from Hacker News

Viper – Go Configuration with Fangs

by maydemir on 5/21/22, 12:00 AM with 3 comments

  • by nemo1618 on 5/23/22, 3:22 AM

    https://github.com/spf13/viper/blob/master/go.mod

    16 direct dependencies, 39 transitive dependencies, and nearly 7000 lines of code -- for a package that handles flags and config files. I can't help feeling that frameworks like this are a little overwrought. It's the sort of project that succeeds because thousands of people just need something that works, right away, so they search for "golang config" and click the top result. Whereas if you can afford to slow down a little, you might find that the stdlib (with a bit of glue) is a perfectly serviceable option for the majority of apps.

  • by knadh on 5/23/22, 4:29 AM

    Use viper with care. It has some dangerous fundamental flaws [1]. We got bitten hard, submitted a PR [2] and followed up for a year and a half to no avail, before I went ahead and reinvented the wheel and wrote koanf (plug), specifically to avoid viper's flaws.

    Most importantly:

    - Breaks JSON, YAML, TOML etc. language specs by forcibly lowercasing all keys internally. Dangerous because it can silently merge differently cased config keys into lowercase.

    - Hard codes big unnecessary dependencies into the core, significantly bloating build sizes. No separation or abstraction.

    [1] https://github.com/spf13/viper/pull/635

    [2] https://github.com/knadh/koanf#alternative-to-viper