Description:
We can create a config package which will implement a LoadConfig() function to read the application configuration from multiple file formats (.yaml, .toml, .json) using the Viper package.
The configuration options can be unmarshaled into a Go struct AppConfig only once at the time of application startup and used to initialize other parts of the application like EspressoService.
Benefits:
- Separate configuration reading logic from the business logic.
- Get rid of raw string literals like
viper.GetString("s3.endpoint")
- Unmarshal into a well-defined Go struct and pass it around for constructing other objects.
I’d like to take this up and implement it.
Description:
We can create a config package which will implement a
LoadConfig()function to read the application configuration from multiple file formats(.yaml, .toml, .json)using the Viper package.The configuration options can be unmarshaled into a Go struct
AppConfigonly once at the time of application startup and used to initialize other parts of the application likeEspressoService.Benefits:
viper.GetString("s3.endpoint")I’d like to take this up and implement it.