package config import ( "fmt" "time" ) type Configuration struct { Timeout int `yaml:"timeout"` Issuer string `yaml:"issuer"` } func (c Configuration) Invalidate() error { if c.Timeout < 1 { c.Timeout = 30 } if c.Issuer == "" { return fmt.Errorf("`issuer` must not be an empty string") } return Invalidate(c) } func (c Configuration) TimeoutDuration() time.Duration { return time.Duration(c.Timeout) * time.Second }