ilyakaznacheev / cleanenv

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

bug: Cleanenv ignore environment variable when using pointer #147

Open afifurrohman-id opened 3 months ago

afifurrohman-id commented 3 months ago

Reproduceable steps:

foo: hello


- `main.go`
```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??