ilyakaznacheev / cleanenv

✨Clean and minimalistic environment configuration reader for Golang
MIT License
1.66k stars 115 forks source link

It changes the set 0 to the default value. #145

Open GoHippo opened 4 months ago

GoHippo commented 4 months ago

conf.yaml : num: 0

type Config struct {
    Num int `yaml:"num" env-default:"1"`
}

func main() {
    var conf Config
    if err := cleanenv.ReadConfig("conf.yaml", &conf); err != nil {
        log.Fatalf("Error reading config file: %v", err)
    }
    fmt.Printf("num:%v\n", conf)
}

result: "num:{1}"