Merge pull request #1031 from vkd/fix-ineffectual-assignments
Fix ineffectual assignments
This commit is contained in:
commit
017c485e4c
@ -79,9 +79,9 @@ func (x *jsonSource) Duration(name string) (time.Duration, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
v, ok := (time.Duration)(0), false
|
v, ok := i.(time.Duration)
|
||||||
if v, ok = i.(time.Duration); !ok {
|
if !ok {
|
||||||
return v, fmt.Errorf("unexpected type %T for %q", i, name)
|
return 0, fmt.Errorf("unexpected type %T for %q", i, name)
|
||||||
}
|
}
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
@ -91,9 +91,9 @@ func (x *jsonSource) Float64(name string) (float64, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
v, ok := (float64)(0), false
|
v, ok := i.(float64)
|
||||||
if v, ok = i.(float64); !ok {
|
if !ok {
|
||||||
return v, fmt.Errorf("unexpected type %T for %q", i, name)
|
return 0, fmt.Errorf("unexpected type %T for %q", i, name)
|
||||||
}
|
}
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
@ -103,9 +103,9 @@ func (x *jsonSource) String(name string) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
v, ok := "", false
|
v, ok := i.(string)
|
||||||
if v, ok = i.(string); !ok {
|
if !ok {
|
||||||
return v, fmt.Errorf("unexpected type %T for %q", i, name)
|
return "", fmt.Errorf("unexpected type %T for %q", i, name)
|
||||||
}
|
}
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
@ -161,9 +161,9 @@ func (x *jsonSource) Generic(name string) (cli.Generic, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
v, ok := (cli.Generic)(nil), false
|
v, ok := i.(cli.Generic)
|
||||||
if v, ok = i.(cli.Generic); !ok {
|
if !ok {
|
||||||
return v, fmt.Errorf("unexpected type %T for %q", i, name)
|
return nil, fmt.Errorf("unexpected type %T for %q", i, name)
|
||||||
}
|
}
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
@ -173,9 +173,9 @@ func (x *jsonSource) Bool(name string) (bool, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
v, ok := false, false
|
v, ok := i.(bool)
|
||||||
if v, ok = i.(bool); !ok {
|
if !ok {
|
||||||
return v, fmt.Errorf("unexpected type %T for %q", i, name)
|
return false, fmt.Errorf("unexpected type %T for %q", i, name)
|
||||||
}
|
}
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,6 @@ func TestMapDuration(t *testing.T) {
|
|||||||
d, err = inputSource.Duration("duration_of_string_type")
|
d, err = inputSource.Duration("duration_of_string_type")
|
||||||
expect(t, time.Minute, d)
|
expect(t, time.Minute, d)
|
||||||
expect(t, nil, err)
|
expect(t, nil, err)
|
||||||
d, err = inputSource.Duration("duration_of_int_type")
|
_, err = inputSource.Duration("duration_of_int_type")
|
||||||
refute(t, nil, err)
|
refute(t, nil, err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user