Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2022-04-02 15:20:13 +03:00
parent 26d5fc5c0e
commit 9a3a9283bd

21
util.go
View File

@ -30,7 +30,7 @@ func (v *mapValue) String() string {
} }
func (v *mapValue) Get() interface{} { func (v *mapValue) Get() interface{} {
return v.v.Interface() return v.v.Interface()
} }
func (v *mapValue) Set(s string) error { func (v *mapValue) Set(s string) error {
@ -87,10 +87,9 @@ func (v *sliceValue) String() string {
return v.def return v.def
} }
func (v *sliceValue) Get() interface{} { func (v *sliceValue) Get() interface{} {
return v.v.Interface() return v.v.Interface()
} }
func (v *sliceValue) Set(s string) error { func (v *sliceValue) Set(s string) error {
p := strings.Split(s, v.delim) p := strings.Split(s, v.delim)
@ -407,19 +406,3 @@ func getFlagOpts(tf string) (string, string, string) {
} }
return name, desc, def return name, desc, def
} }
func isZeroValue(f *flag.Flag, value string) bool {
// Build a zero value of the flag's Value type, and see if the
// result of calling its String method equals the value passed in.
// This works unless the Value type is itself an interface type.
typ := reflect.TypeOf(f.Value)
var z reflect.Value
if typ.Kind() == reflect.Pointer {
z = reflect.New(typ.Elem())
} else {
z = reflect.Zero(typ)
}
return value == z.Interface().(flag.Value).String()
}