Add Go vetting to Travis CI configuration (#128)

* Fix go vet warning in various go source files

Signed-off-by: Dennis Adjei-Baah <dennis@buoyant.io>
This commit is contained in:
Dennis Adjei-Baah 2018-01-09 15:21:41 -08:00 committed by GitHub
parent 0ee38e46f8
commit 2b22d4bc63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 9 deletions

View File

@ -42,6 +42,7 @@ jobs:
# this or we should error if it dirties the repo.
- ./bin/protoc-go.sh
- go test -v ./...
- go vet ./...
- language: node_js
node_js:
- "8"

View File

@ -85,7 +85,7 @@ func (kctl *kubectl) StartProxy(potentialErrorWhenStartingProxy chan error, port
fmt.Printf("Running `kubectl proxy -p %d`\n", port)
if kctl.ProxyPort() != portWhenProxyNotRunning {
return fmt.Errorf("kubectl proxy already running on port [%d]", kctl.ProxyPort)
return fmt.Errorf("kubectl proxy already running on port [%d]", kctl.ProxyPort())
}
output, err := kctl.sh.AsyncStdout(potentialErrorWhenStartingProxy, "kubectl", "proxy", "-p", strconv.Itoa(port))

View File

@ -77,7 +77,7 @@ func TestKubectlStartProxy(t *testing.T) {
}
if kctl.ProxyPort() != kubectlDefaultProxyPort {
t.Fatalf("Expecting proxy to be running on [%d] but it's on [%d]", kubectlDefaultProxyPort, kctl.ProxyPort)
t.Fatalf("Expecting proxy to be running on [%d] but it's on [%d]", kubectlDefaultProxyPort, kctl.ProxyPort())
}
if shell.LastFullCommand() != "kubectl proxy -p 8001" {
@ -105,7 +105,7 @@ func TestKubectlStartProxy(t *testing.T) {
}
if kctl.ProxyPort() != kubectlDefaultProxyPort {
t.Fatalf("Expected proxy to keep running on port [%d] but got [%d]", kubectlDefaultProxyPort, kctl.ProxyPort)
t.Fatalf("Expected proxy to keep running on port [%d] but got [%d]", kubectlDefaultProxyPort, kctl.ProxyPort())
}
})

View File

@ -100,7 +100,7 @@ func TestWaitForCharacter(t *testing.T) {
}
if strings.TrimSpace(outputString) != expectedOutput {
t.Fatalf("Expecting command output to be [%s], got [%s]", expectedOutput, output)
t.Fatalf("Expecting command output to be [%s], got [%s]", expectedOutput, strings.TrimSpace(outputString))
}
select {

View File

@ -195,7 +195,7 @@ func expectCannotConnectGetRequestTo(t *testing.T, host string, port string) {
fmt.Printf("Expecting failed GET to %s\n", targetUrl)
resp, err := http.Get(targetUrl)
if err == nil {
t.Fatalf("Expected error when connecting to %s, got:\n%s", targetUrl, resp)
t.Fatalf("Expected error when connecting to %s, got:\n%+v", targetUrl, resp)
}
}

View File

@ -47,7 +47,7 @@ func response() string {
}
func main() {
fmt.Printf("Starting stub HTTP server on port [%s] will serve [%s] proxy [%s]", port, hostname, amITheProxy)
fmt.Printf("Starting stub HTTP server on port [%s] will serve [%s] proxy [%t]", port, hostname, amITheProxy)
http.HandleFunc("/", returnHostAndPortHandler)
http.HandleFunc("/call", callOtherServiceHandler)

View File

@ -38,11 +38,11 @@ func main() {
_, _, err = net.SplitHostPort(*kubernetesApiHost) // Verify kubernetesApiHost is of the form host:port.
if err != nil {
log.Fatalf("failed to parse API server address: %s", kubernetesApiHost)
log.Fatalf("failed to parse API server address: %s", *kubernetesApiHost)
}
client, err := public.NewInternalClient(*kubernetesApiHost)
if err != nil {
log.Fatalf("failed to construct client for API server URL %s", kubernetesApiHost)
log.Fatalf("failed to construct client for API server URL %s", *kubernetesApiHost)
}
stop := make(chan os.Signal, 1)
@ -64,6 +64,7 @@ func main() {
<-stop
log.Info("shutting down HTTP server on", *addr)
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
server.Shutdown(ctx)
}