Open lyricnz opened 2 years ago
There's a million "configuration frameworks" for golang, but we should try and be careful not to add another poorly maintained (or overly complex/big) upstream just for this. eg https://reposhub.com/go/configuration
(not a suggestion - thinking out loud) Some of my workmates suggest:
YMMV, but separating validation from load/parse can often simplify too Have used this in the past: https://github.com/go-playground/validator
In Go you can get a lot of typing/structure very easily. If you use https://pkg.go.dev/gopkg.in/yaml.v2#Unmarshal the type/structure is defined in go structs, and the library will expect sequence/mappings and certain YAML values depending on the corresponding struct/field in Go.
Viper looks good, but probably major overkill https://github.com/spf13/viper And fwiw Cobra could manage/generate our CLI interfaces (but would be refactor without end-user value)
At the moment there's a lot of code necessary for accessing the configuration file, and updating it is a real headache. We should consider something more declarative, so we can modify more-or-less one place, and have it work properly (load/save etc). Also, coordinating the command-line args and environment variables vs config would be nice.
This probably relates to "Don't store app state in configuration file #238"