cleanenv
cleanenv copied to clipboard
bug: Cleanenv ignore environment variable when using pointer
Reproduceable steps:
-
config.yaml
foo: hello
-
main.go
package main
import (
"fmt"
"github.com/ilyakaznacheev/cleanenv"
)
type (
Config struct {
Foo *string `env-required:"true" yaml:"foo" env:"FOO"`
}
)
func main() {
cfg := new(Config)
_ = cleanenv.ReadConfig("config.yaml", cfg)
cleanenv.ReadEnv(cfg)
fmt.Println(*cfg.Foo)
}
export FOO=bar
it will print "hello" instead of bar
is this limitation of reflection??