From 8c408324d40d960f9e28a8f011e543479ef918d8 Mon Sep 17 00:00:00 2001 From: Functionary Robot Date: Thu, 19 Apr 2018 11:47:46 +1000 Subject: [PATCH] lib: fix errors found by vet Vet found the following errors: lib/proxy.go:87: result of fmt.Errorf call not used lib/proxy.go:97: result of fmt.Errorf call not used lib/proxy.go:105: result of fmt.Errorf call not used These are pointless calls because fmt.Errorf just creates an error value; it is then discarded without reporting the error to the user. This commit changes the fmt.Errorf calls to log.Printf calls so the error is logged. --- lib/proxy.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/proxy.go b/lib/proxy.go index d559cac..187df01 100644 --- a/lib/proxy.go +++ b/lib/proxy.go @@ -4,6 +4,7 @@ import ( "crypto/tls" "fmt" "io" + "log" "net" "net/http" "net/http/httputil" @@ -84,7 +85,7 @@ func proxyWebsocket(w http.ResponseWriter, r *http.Request, host *url.URL) { d, err := net.Dial("tcp", host.Host) if err != nil { http.Error(w, "Error contacting backend server.", 500) - fmt.Errorf("Error dialing websocket backend %s: %v", host, err) + log.Printf("Error dialing websocket backend %s: %v", host, err) return } hj, ok := w.(http.Hijacker) @@ -94,7 +95,7 @@ func proxyWebsocket(w http.ResponseWriter, r *http.Request, host *url.URL) { } nc, _, err := hj.Hijack() if err != nil { - fmt.Errorf("Hijack error: %v", err) + log.Printf("Hijack error: %v", err) return } defer nc.Close() @@ -102,7 +103,7 @@ func proxyWebsocket(w http.ResponseWriter, r *http.Request, host *url.URL) { err = r.Write(d) if err != nil { - fmt.Errorf("Error copying request to target: %v", err) + log.Printf("Error copying request to target: %v", err) return }