Verify whether there is a Value before overriding

This commit is contained in:
Vinicius Schettino 2020-07-11 15:54:46 -03:00
parent 8e16b98d40
commit 7ecfd216b1

View File

@ -118,7 +118,9 @@ func (f *TimestampFlag) Apply(set *flag.FlagSet) error {
if f.Layout == "" {
return fmt.Errorf("timestamp Layout is required")
}
f.Value = &Timestamp{}
if f.Value == nil {
f.Value = &Timestamp{}
}
f.Value.SetLayout(f.Layout)
if val, ok := flagFromEnvOrFile(f.EnvVars, f.FilePath); ok {