You can skip tons of the boilerplate here by using https://github.com/spf13/viper . I have used viper for my last few projects and it’s a huge timesaver. Supports TOML, as well as a bunch of other formats.
I touched on this a bit in the reddit discussion, but I’ll expand here.
I’ve checked out viper, but I personally don’t care for it for a couple reasons:
I haven’t explored viper a whole lot, so I’m sure there are other advantages. This approach has worked marvelously for me for several command-line applications, and I haven’t felt like I’m missing any necessary features.
Thanks for your response! I agree with all your points, I’ve just found viper to be a good solution when I don’t want/don’t need to think about config too much but it’s clearly needed. I certainly still think everything you wrote is valuable and shouldn’t have implied otherwise.
I built a tiny lib for working with json configs and go’s flag lib: https://github.com/zamicol/jsonflags