Commit dd3856e1 authored by David Symonds's avatar David Symonds

flag: add a little more doc comment to Duration.

The only text that describes the accepted format is in the package doc,
which is far away from these functions. The other flag types don't need
this explicitness because they are more obvious.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/101550043
parent 8c8bf3cc
...@@ -628,18 +628,21 @@ func Float64(name string, value float64, usage string) *float64 { ...@@ -628,18 +628,21 @@ func Float64(name string, value float64, usage string) *float64 {
// DurationVar defines a time.Duration flag with specified name, default value, and usage string. // DurationVar defines a time.Duration flag with specified name, default value, and usage string.
// The argument p points to a time.Duration variable in which to store the value of the flag. // The argument p points to a time.Duration variable in which to store the value of the flag.
// The flag accepts a value acceptable to time.ParseDuration.
func (f *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string) { func (f *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string) {
f.Var(newDurationValue(value, p), name, usage) f.Var(newDurationValue(value, p), name, usage)
} }
// DurationVar defines a time.Duration flag with specified name, default value, and usage string. // DurationVar defines a time.Duration flag with specified name, default value, and usage string.
// The argument p points to a time.Duration variable in which to store the value of the flag. // The argument p points to a time.Duration variable in which to store the value of the flag.
// The flag accepts a value acceptable to time.ParseDuration.
func DurationVar(p *time.Duration, name string, value time.Duration, usage string) { func DurationVar(p *time.Duration, name string, value time.Duration, usage string) {
CommandLine.Var(newDurationValue(value, p), name, usage) CommandLine.Var(newDurationValue(value, p), name, usage)
} }
// Duration defines a time.Duration flag with specified name, default value, and usage string. // Duration defines a time.Duration flag with specified name, default value, and usage string.
// The return value is the address of a time.Duration variable that stores the value of the flag. // The return value is the address of a time.Duration variable that stores the value of the flag.
// The flag accepts a value acceptable to time.ParseDuration.
func (f *FlagSet) Duration(name string, value time.Duration, usage string) *time.Duration { func (f *FlagSet) Duration(name string, value time.Duration, usage string) *time.Duration {
p := new(time.Duration) p := new(time.Duration)
f.DurationVar(p, name, value, usage) f.DurationVar(p, name, value, usage)
...@@ -648,6 +651,7 @@ func (f *FlagSet) Duration(name string, value time.Duration, usage string) *time ...@@ -648,6 +651,7 @@ func (f *FlagSet) Duration(name string, value time.Duration, usage string) *time
// Duration defines a time.Duration flag with specified name, default value, and usage string. // Duration defines a time.Duration flag with specified name, default value, and usage string.
// The return value is the address of a time.Duration variable that stores the value of the flag. // The return value is the address of a time.Duration variable that stores the value of the flag.
// The flag accepts a value acceptable to time.ParseDuration.
func Duration(name string, value time.Duration, usage string) *time.Duration { func Duration(name string, value time.Duration, usage string) *time.Duration {
return CommandLine.Duration(name, value, usage) return CommandLine.Duration(name, value, usage)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment