darius-khll / golang-developer-roadmap

Roadmap to becoming a Go developer in 2020
17.94k stars 2.16k forks source link

Any recommendation for configuration management package? #85

Open hdw868 opened 3 years ago

hdw868 commented 3 years ago

There could be a lot of approach to store your configuration to some file such as JSON, YAML, TOML, INI and etc. I wonder what's the proposed way to read/write configuration file in golang?

ngopher commented 3 years ago

@hdw868 Please provide some more explanation.

hdw868 commented 3 years ago

@hdw868 Please provide some more explanation.

I edit my description : )

mofodox commented 2 years ago

There could be a lot of approach to store your configuration to some file such as JSON, YAML, TOML, INI and etc. I wonder what's the proposed way to read/write configuration file in golang?

@hdw868 Well you can use the built-in os package to read and write files.

kunapyanov commented 2 years ago

Viper is good choice if you want some complicated logic and wanna keep it easier to handle. Like JSON(YAML) + env variables. But it could be overwhelmed if you have just a few variables, then os(to read) and any package to parse json or yaml or whatever you want would be enough. That is my view :) Also take a look at this list of packages