We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using a non-struct pointer value, we cannot pass in existing data.
package main import ( "encoding/json" "fmt" "log" "os" "github.com/caarlos0/env/v6" "k8s.io/utils/pointer" ) type Test struct { // Bool *bool `env:"TEST"` Str *string `env:"TEST"` } type ComplexConfig struct { Foo Test `envPrefix:"FOO_"` Bar Test `envPrefix:"BAR_"` D Test `envPrefix:"D_"` } func main() { os.Setenv("FOO_TEST", "1") os.Setenv("BAR_TEST", "0") cfg := ComplexConfig{ D: Test{ Str: pointer.String("hello"), // Bool: pointer.Bool(true), }, } err := env.Parse(&cfg) if err != nil { log.Fatal(err) } confBytes, _ := json.Marshal(cfg) fmt.Printf("%s", confBytes) }
Result
env: env: expected a pointer to a Struct
It works fine if the cfg variable had nothing set for D (ie, cfg := ComplexConfig{}):
cfg
D
cfg := ComplexConfig{}
{"Foo":{"Str":"1"},"Bar":{"Str":"0"},"D":{"Str":null}}
The use-case for this is to use it with our Installer to fill in the configuration
The text was updated successfully, but these errors were encountered:
@caarlos0 are you going to take a look or can I try to investigate?
Sorry, something went wrong.
feel free to try, I don't know when I'll have the time to look into it
fixed in #236
Thanks @caarlos0
No branches or pull requests
When using a non-struct pointer value, we cannot pass in existing data.
Result
It works fine if the
cfg
variable had nothing set forD
(ie,cfg := ComplexConfig{}
):The use-case for this is to use it with our Installer to fill in the configuration
The text was updated successfully, but these errors were encountered: