Skip to content

Commit

Permalink
Remove redundant variable declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyifyj committed Mar 29, 2023
1 parent 31b7abb commit ce70743
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
9 changes: 2 additions & 7 deletions flag_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,8 @@ func (cCtx *Context) Generic(name string) interface{} {
}

func lookupGeneric(name string, set *flag.FlagSet) interface{} {
f := set.Lookup(name)
if f != nil {
parsed, err := f.Value, error(nil)
if err != nil {
return nil
}
return parsed
if f := set.Lookup(name); f != nil {
return f.Value
}
return nil
}
9 changes: 2 additions & 7 deletions flag_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,8 @@ func (cCtx *Context) Path(name string) string {
}

func lookupPath(name string, set *flag.FlagSet) string {
f := set.Lookup(name)
if f != nil {
parsed, err := f.Value.String(), error(nil)
if err != nil {
return ""
}
return parsed
if f := set.Lookup(name); f != nil {
return f.Value.String()
}
return ""
}
6 changes: 2 additions & 4 deletions flag_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ func (cCtx *Context) String(name string) string {
}

func lookupString(name string, set *flag.FlagSet) string {
f := set.Lookup(name)
if f != nil {
parsed := f.Value.String()
return parsed
if f := set.Lookup(name); f != nil {
return f.Value.String()
}
return ""
}

0 comments on commit ce70743

Please sign in to comment.