You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In practice, array-type fields are often used, and they should be supported, perhaps not necessarily required, but useful
Such as string slice, using a single name to accept multiple values, such a requirement exists in command-line programs
// -- strings ValuetypestringsValue []stringfuncnewStringsValue(val []string, p*[]string) *stringsValue {
*p=valreturn (*stringsValue)(p)
}
func (s*stringsValue) Set(valstring) error {
*s=append(*s, val)
returnnil
}
func (s*stringsValue) Get() any { return []string(*s) }
func (s*stringsValue) String() string { returnfmt.Sprint([]string(*s)) }
// StringsVar defines many string flag with specified name, default value, and usage string.// The argument p points to many string variable in which to store the value of the flag.func (f*FlagSet) StringsVar(p*[]string, namestring, value []string, usagestring) {
f.Var(newStringsValue(value, p), name, usage)
}
// StringsVar defines many string flag with specified name, default value, and usage string.// The argument p points to many string variable in which to store the value of the flag.funcStringsVar(p*[]string, namestring, value []string, usagestring) {
CommandLine.Var(newStringsValue(value, p), name, usage)
}
// Strings defines many string flag with specified name, default value, and usage string.// The return value is the address of many string variable that stores the value of the flag.func (f*FlagSet) Strings(namestring, value []string, usagestring) *[]string {
p:=new([]string)
f.StringsVar(p, name, value, usage)
returnp
}
// Strings defines many string flag with specified name, default value, and usage string.// The return value is the address of many string variable that stores the value of the flag.funcStrings(namestring, value []string, usagestring) *[]string {
returnCommandLine.Strings(name, value, usage)
}
The text was updated successfully, but these errors were encountered:
Proposal Details
Proposal Details
In practice, array-type fields are often used, and they should be supported, perhaps not necessarily required, but useful
Such as string slice, using a single name to accept multiple values, such a requirement exists in command-line programs
The text was updated successfully, but these errors were encountered: