Skip to content

Instantly share code, notes, and snippets.

@iyusa
Created July 23, 2021 08:37
Show Gist options
  • Save iyusa/5dab851eda282dd315477d2503b6d73e to your computer and use it in GitHub Desktop.
Save iyusa/5dab851eda282dd315477d2503b6d73e to your computer and use it in GitHub Desktop.
[Go Env Config]#config #go
package common
import "github.com/ilyakaznacheev/cleanenv"
// Config for all
var Config config
type config struct {
Port int `yaml:"port"`
DB string `yaml:"db"`
}
// LoadConfig yaml from file
func LoadConfig(filename string) {
if cleanenv.ReadConfig(filename, &Config) != nil {
Config.Port = 5555
Config.DB = "survey:survey123@/survey?charset=utf8&parseTime=True"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment