kelseyhightower / envconfig

Golang library for managing configuration data from environment variables
MIT License
5.01k stars 377 forks source link

Invalid time fields are parsed without error #212

Closed pcurren-atlassian closed 4 months ago

pcurren-atlassian commented 4 months ago

Example struct configuration:

type WorkerConfig struct {
    ThingA   int                    `default:"100"`
    ThingB   time.Duration `split_words:"true" default:"10s"`
    Thing C string               `split_words:"true" required:"true"`
}

If I set an environment variable called WORKER_THING_B with an non parsable time like "1abcd"

And then parse with:

func (wc *WorkerConfig) Process() error {
    return envconfig.Process("worker", wc)
}

I would expect an error but instead the WorkerConfig has a default "zero" value for ThingB.

pcurren-atlassian commented 4 months ago

Version: github.com/kelseyhightower/envconfig v1.4.0

pcurren-atlassian commented 4 months ago

My mistake! Sorry for wasting your time. It does error!