Go Conf Builder is a lightweight configuration library inspired by Viper. It allows loading configuration values from various file formats and environment variables.
go get github.com/mirkobrombin/go-conf-builder
cfg := conf.New()
cfg.SetConfigName("config")
cfg.AddConfigPath(".")
cfg.SetEnvPrefix("MYAPP")
cfg.AutomaticEnv()
cfg.SetDefault("port", 8080)
if err := cfg.ReadInConfig(); err != nil {
fmt.Println("error loading config:", err)
}
fmt.Println("port:", cfg.GetInt("port"))
See the docs for more details.
This project is licensed under the MIT License. See the LICENSE file for details.