Correcting all go vet errors

This commit is contained in:
Kris Rousey
2015-08-07 18:52:23 -07:00
parent 9fdd793555
commit 565189f5b8
118 changed files with 285 additions and 298 deletions

View File

@@ -26,7 +26,7 @@ import (
func ExpectValue(t *testing.T, atomicValue *AtomicValue, expectedValue interface{}) {
actualValue := atomicValue.Load()
if actualValue != expectedValue {
t.Error("Expected to find %v, found %v", expectedValue, actualValue)
t.Errorf("Expected to find %v, found %v", expectedValue, actualValue)
}
ch := make(chan interface{})
go func() {
@@ -35,7 +35,7 @@ func ExpectValue(t *testing.T, atomicValue *AtomicValue, expectedValue interface
select {
case actualValue = <-ch:
if actualValue != expectedValue {
t.Error("Expected to find %v, found %v", expectedValue, actualValue)
t.Errorf("Expected to find %v, found %v", expectedValue, actualValue)
return
}
case <-time.After(time.Second * 5):

View File

@@ -142,7 +142,7 @@ func (s *SpdyRoundTripper) NewConnection(resp *http.Response) (httpstream.Connec
} else {
if obj, err := api.Scheme.Decode(responseErrorBytes); err == nil {
if status, ok := obj.(*api.Status); ok {
return nil, &apierrors.StatusError{*status}
return nil, &apierrors.StatusError{ErrStatus: *status}
}
}
responseError = string(responseErrorBytes)

View File

@@ -39,9 +39,9 @@ func testEnsureChain(t *testing.T, protocol Protocol) {
// Success.
func() ([]byte, error) { return []byte{}, nil },
// Exists.
func() ([]byte, error) { return nil, &exec.FakeExitError{1} },
func() ([]byte, error) { return nil, &exec.FakeExitError{Status: 1} },
// Failure.
func() ([]byte, error) { return nil, &exec.FakeExitError{2} },
func() ([]byte, error) { return nil, &exec.FakeExitError{Status: 2} },
},
}
fexec := exec.FakeExec{
@@ -96,7 +96,7 @@ func TestFlushChain(t *testing.T) {
// Success.
func() ([]byte, error) { return []byte{}, nil },
// Failure.
func() ([]byte, error) { return nil, &exec.FakeExitError{1} },
func() ([]byte, error) { return nil, &exec.FakeExitError{Status: 1} },
},
}
fexec := exec.FakeExec{
@@ -130,7 +130,7 @@ func TestDeleteChain(t *testing.T) {
// Success.
func() ([]byte, error) { return []byte{}, nil },
// Failure.
func() ([]byte, error) { return nil, &exec.FakeExitError{1} },
func() ([]byte, error) { return nil, &exec.FakeExitError{Status: 1} },
},
}
fexec := exec.FakeExec{
@@ -197,7 +197,7 @@ func TestEnsureRuleNew(t *testing.T) {
// iptables version check
func() ([]byte, error) { return []byte("iptables v1.9.22"), nil },
// Status 1 on the first call.
func() ([]byte, error) { return nil, &exec.FakeExitError{1} },
func() ([]byte, error) { return nil, &exec.FakeExitError{Status: 1} },
// Success on the second call.
func() ([]byte, error) { return []byte{}, nil },
},
@@ -233,7 +233,7 @@ func TestEnsureRuleErrorChecking(t *testing.T) {
// iptables version check
func() ([]byte, error) { return []byte("iptables v1.9.22"), nil },
// Status 2 on the first call.
func() ([]byte, error) { return nil, &exec.FakeExitError{2} },
func() ([]byte, error) { return nil, &exec.FakeExitError{Status: 2} },
},
}
fexec := exec.FakeExec{
@@ -260,9 +260,9 @@ func TestEnsureRuleErrorCreating(t *testing.T) {
// iptables version check
func() ([]byte, error) { return []byte("iptables v1.9.22"), nil },
// Status 1 on the first call.
func() ([]byte, error) { return nil, &exec.FakeExitError{1} },
func() ([]byte, error) { return nil, &exec.FakeExitError{Status: 1} },
// Status 1 on the second call.
func() ([]byte, error) { return nil, &exec.FakeExitError{1} },
func() ([]byte, error) { return nil, &exec.FakeExitError{Status: 1} },
},
}
fexec := exec.FakeExec{
@@ -290,7 +290,7 @@ func TestDeleteRuleAlreadyExists(t *testing.T) {
// iptables version check
func() ([]byte, error) { return []byte("iptables v1.9.22"), nil },
// Status 1 on the first call.
func() ([]byte, error) { return nil, &exec.FakeExitError{1} },
func() ([]byte, error) { return nil, &exec.FakeExitError{Status: 1} },
},
}
fexec := exec.FakeExec{
@@ -353,7 +353,7 @@ func TestDeleteRuleErrorChecking(t *testing.T) {
// iptables version check
func() ([]byte, error) { return []byte("iptables v1.9.22"), nil },
// Status 2 on the first call.
func() ([]byte, error) { return nil, &exec.FakeExitError{2} },
func() ([]byte, error) { return nil, &exec.FakeExitError{Status: 2} },
},
}
fexec := exec.FakeExec{
@@ -382,7 +382,7 @@ func TestDeleteRuleErrorCreating(t *testing.T) {
// Success on the first call.
func() ([]byte, error) { return []byte{}, nil },
// Status 1 on the second call.
func() ([]byte, error) { return nil, &exec.FakeExitError{1} },
func() ([]byte, error) { return nil, &exec.FakeExitError{Status: 1} },
},
}
fexec := exec.FakeExec{

View File

@@ -298,7 +298,7 @@ Loop:
params[i].Known = true
params[i].Value, err = strconv.Atoi(value[i])
if err != nil {
return fmt.Errorf("array index %s is not a number", params[i].Value)
return fmt.Errorf("array index %s is not a number", value[i])
}
}
} else {

View File

@@ -148,7 +148,7 @@ func verifyNoError(t *testing.T, err error, name string) {
func verifyError(t *testing.T, err error, name string) {
if err == nil {
t.Fatalf("Unexpected response on %q. Expected: <error> Actual: <no error>")
t.Fatalf("Unexpected response on %q. Expected: <error> Actual: <no error>", name)
}
}

View File

@@ -59,7 +59,7 @@ func TestSplitPort(t *testing.T) {
t.Errorf("%q: Wanted %q, got %q", item.in, e, a)
}
if e, a := item.valid, valid; e != a {
t.Errorf("%q: Wanted %q, got %q", item.in, e, a)
t.Errorf("%q: Wanted %t, got %t", item.in, e, a)
}
}
}

View File

@@ -158,14 +158,14 @@ func TestIsValidPortName(t *testing.T) {
goodValues := []string{"telnet", "re-mail-ck", "pop3", "a", "a-1", "1-a", "a-1-b-2-c", "1-a-2-b-3"}
for _, val := range goodValues {
if !IsValidPortName(val) {
t.Errorf("expected true for '%d'", val)
t.Errorf("expected true for %q", val)
}
}
badValues := []string{"longerthan15characters", "", "12345", "1-2-3-4", "-begin", "end-", "two--hyphens", "1-2", "whois++"}
for _, val := range badValues {
if IsValidPortName(val) {
t.Errorf("expected false for '%d'", val)
t.Errorf("expected false for %q", val)
}
}
}