Initialize nil pointers
- Dominant language
- Go
- Stars
- 6.3k
- Forks
- 284
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 1
Description
Why `NilInner *Inner` stay `nil` when we explicitly set the environment variable?
```
func ExampleParse_init() {
os.Setenv("OLA", "HI") // new added line
type Inner struct {
A string `env:"OLA" envDefault:"HI"`
}
type Config struct {
NilInner *Inner
InitInner *Inner `env:",init"`
}
var cfg Config
if err := Parse(&cfg); err != nil {
fmt.Println(err)
}
fmt.Print(cfg.NilInner, cfg.InitInner)
// Output: &{HI}
}
```
Is this the expected behavior?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the Parse call and the ExampleParse_init example shown in the issue, comparing the untagged NilInner pointer with InitInner tagged env:",init". Check how pointer fields are handled when the environment variable is present, then determine whether the example's output matches the intended behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100