From 7ecfd216b14542e1bec159d58d5d7af992969bf8 Mon Sep 17 00:00:00 2001 From: Vinicius Schettino Date: Sat, 11 Jul 2020 15:54:46 -0300 Subject: [PATCH] Verify whether there is a Value before overriding --- flag_timestamp.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flag_timestamp.go b/flag_timestamp.go index 9fac1d1..0382a6b 100644 --- a/flag_timestamp.go +++ b/flag_timestamp.go @@ -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 {