Skip to content

Commit

Permalink
Merge pull request #1714 from huiyifyj/v2-remove-var
Browse files Browse the repository at this point in the history
Remove redundant variable declarations
  • Loading branch information
dearchap authored Mar 29, 2023
2 parents 31b7abb + ce70743 commit c0cc5c2
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 c0cc5c2

Please sign in to comment.