From e3be2ebcffcc36be35e23d418d3e0ba86239826a Mon Sep 17 00:00:00 2001 From: Tomas Aschan <1550920+tomasaschan@users.noreply.github.com> Date: Wed, 16 Jul 2025 23:38:11 +0200 Subject: Reduce duplication by forwarding to sibling functions --- time.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/time.go b/time.go index dbaeeab..dc02480 100644 --- a/time.go +++ b/time.go @@ -74,7 +74,7 @@ func (f *FlagSet) GetTime(name string) (time.Time, error) { // TimeVar defines a time.Time flag with specified name, default value, and usage string. // The argument p points to a time.Time variable in which to store the value of the flag. func (f *FlagSet) TimeVar(p *time.Time, name string, value time.Time, formats []string, usage string) { - f.VarP(newTimeValue(value, p, formats), name, "", usage) + f.TimeVarP(p, name, "", value, formats, usage) } // TimeVarP is like TimeVar, but accepts a shorthand letter that can be used after a single dash. @@ -85,7 +85,7 @@ func (f *FlagSet) TimeVarP(p *time.Time, name, shorthand string, value time.Time // TimeVar defines a time.Time flag with specified name, default value, and usage string. // The argument p points to a time.Time variable in which to store the value of the flag. func TimeVar(p *time.Time, name string, value time.Time, formats []string, usage string) { - CommandLine.VarP(newTimeValue(value, p, formats), name, "", usage) + CommandLine.TimeVarP(p, name, "", value, formats, usage) } // TimeVarP is like TimeVar, but accepts a shorthand letter that can be used after a single dash. @@ -96,9 +96,7 @@ func TimeVarP(p *time.Time, name, shorthand string, value time.Time, formats []s // Time defines a time.Time flag with specified name, default value, and usage string. // The return value is the address of a time.Time variable that stores the value of the flag. func (f *FlagSet) Time(name string, value time.Time, formats []string, usage string) *time.Time { - p := new(time.Time) - f.TimeVarP(p, name, "", value, formats, usage) - return p + return f.TimeP(name, "", value, formats, usage) } // TimeP is like Time, but accepts a shorthand letter that can be used after a single dash. -- cgit v1.2.3