Skip to content

Commit

Permalink
Merge pull request #1031 from vkd/fix-ineffectual-assignments
Browse files Browse the repository at this point in the history
Fix ineffectual assignments
  • Loading branch information
coilysiren committed Jan 1, 2020
2 parents b431442 + 0da9781 commit 017c485
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 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)
}

0 comments on commit 017c485

Please sign in to comment.