Skip to content

Commit

Permalink
Merge branch 'master' into suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
saschagrunert committed Jan 2, 2020
2 parents c949e05 + 017c485 commit 6d71d67
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 34 deletions.
30 changes: 15 additions & 15 deletions altsrc/json_source_context.go
Expand Up @@ -79,9 +79,9 @@ func (x *jsonSource) Duration(name string) (time.Duration, error) {
if err != nil {
return 0, err
}
v, ok := (time.Duration)(0), false
if v, ok = i.(time.Duration); !ok {
return v, fmt.Errorf("unexpected type %T for %q", i, name)
v, ok := i.(time.Duration)
if !ok {
return 0, fmt.Errorf("unexpected type %T for %q", i, name)
}
return v, nil
}
Expand All @@ -91,9 +91,9 @@ func (x *jsonSource) Float64(name string) (float64, error) {
if err != nil {
return 0, err
}
v, ok := (float64)(0), false
if v, ok = i.(float64); !ok {
return v, fmt.Errorf("unexpected type %T for %q", i, name)
v, ok := i.(float64)
if !ok {
return 0, fmt.Errorf("unexpected type %T for %q", i, name)
}
return v, nil
}
Expand All @@ -103,9 +103,9 @@ func (x *jsonSource) String(name string) (string, error) {
if err != nil {
return "", err
}
v, ok := "", false
if v, ok = i.(string); !ok {
return v, fmt.Errorf("unexpected type %T for %q", i, name)
v, ok := i.(string)
if !ok {
return "", fmt.Errorf("unexpected type %T for %q", i, name)
}
return v, nil
}
Expand Down Expand Up @@ -161,9 +161,9 @@ func (x *jsonSource) Generic(name string) (cli.Generic, error) {
if err != nil {
return nil, err
}
v, ok := (cli.Generic)(nil), false
if v, ok = i.(cli.Generic); !ok {
return v, fmt.Errorf("unexpected type %T for %q", i, name)
v, ok := i.(cli.Generic)
if !ok {
return nil, fmt.Errorf("unexpected type %T for %q", i, name)
}
return v, nil
}
Expand All @@ -173,9 +173,9 @@ func (x *jsonSource) Bool(name string) (bool, error) {
if err != nil {
return false, err
}
v, ok := false, false
if v, ok = i.(bool); !ok {
return v, fmt.Errorf("unexpected type %T for %q", i, name)
v, ok := i.(bool)
if !ok {
return false, fmt.Errorf("unexpected type %T for %q", i, name)
}
return v, nil
}
Expand Down
2 changes: 1 addition & 1 deletion altsrc/map_input_source_test.go
Expand Up @@ -20,6 +20,6 @@ func TestMapDuration(t *testing.T) {
d, err = inputSource.Duration("duration_of_string_type")
expect(t, time.Minute, d)
expect(t, nil, err)
d, err = inputSource.Duration("duration_of_int_type")
_, err = inputSource.Duration("duration_of_int_type")
refute(t, nil, err)
}
11 changes: 0 additions & 11 deletions app.go
Expand Up @@ -7,7 +7,6 @@ import (
"io"
"os"
"path/filepath"
"reflect"
"sort"
"time"
)
Expand Down Expand Up @@ -497,16 +496,6 @@ func (a *App) VisibleFlags() []Flag {
return visibleFlags(a.Flags)
}

func (a *App) hasFlag(flag Flag) bool {
for _, f := range a.Flags {
if reflect.DeepEqual(flag, f) {
return true
}
}

return false
}

func (a *App) errWriter() io.Writer {
// When the app ErrWriter is nil use the package level one.
if a.ErrWriter == nil {
Expand Down
1 change: 0 additions & 1 deletion context.go
Expand Up @@ -17,7 +17,6 @@ type Context struct {
App *App
Command *Command
shellComplete bool
setFlags map[string]bool
flagSet *flag.FlagSet
parentContext *Context
}
Expand Down
6 changes: 0 additions & 6 deletions helpers_test.go
Expand Up @@ -24,9 +24,3 @@ func expect(t *testing.T, a interface{}, b interface{}) {
t.Errorf("(%s:%d) Expected %v (type %v) - Got %v (type %v)", fn, line, b, reflect.TypeOf(b), a, reflect.TypeOf(a))
}
}

func refute(t *testing.T, a interface{}, b interface{}) {
if reflect.DeepEqual(a, b) {
t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
}
}

0 comments on commit 6d71d67

Please sign in to comment.