diff --git a/.golangci.yml b/.golangci.yml index 29a5a2c8c9d69..2b8c9e779a6f3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,7 +9,6 @@ linters: disable: - deadcode - errcheck - - gosimple - staticcheck - structcheck - unused diff --git a/cli/cmd/endpoints.go b/cli/cmd/endpoints.go index c838427a3c702..473fccf58dfde 100644 --- a/cli/cmd/endpoints.go +++ b/cli/cmd/endpoints.go @@ -104,7 +104,7 @@ func renderEndpoints(endpoints *pb.EndpointsResponse, options *endpointsOptions) writeEndpointsToBuffer(endpoints, w, options) w.Flush() - return string(buffer.Bytes()) + return buffer.String() } type rowEndpoint struct { diff --git a/cli/cmd/root.go b/cli/cmd/root.go index 55f17ba17e117..a5af7798687d4 100644 --- a/cli/cmd/root.go +++ b/cli/cmd/root.go @@ -200,7 +200,7 @@ func renderStats(buffer bytes.Buffer, options *statOptionsBase) string { var out string switch options.outputFormat { case "json": - out = string(buffer.Bytes()) + out = buffer.String() default: // strip left padding on the first column out = string(buffer.Bytes()[padding:]) diff --git a/controller/k8s/api_test.go b/controller/k8s/api_test.go index 654820f520bdb..ff843b2795527 100644 --- a/controller/k8s/api_test.go +++ b/controller/k8s/api_test.go @@ -27,9 +27,7 @@ func newAPI(resourceConfigs []string, extraConfigs ...string) (*API, []runtime.O k8sResults = append(k8sResults, obj) } - for _, config := range extraConfigs { - k8sConfigs = append(k8sConfigs, config) - } + k8sConfigs = append(k8sConfigs, extraConfigs...) api, err := NewFakeAPI("", k8sConfigs...) if err != nil { diff --git a/controller/proxy-injector/server_test.go b/controller/proxy-injector/server_test.go index e8fcd4c54ee69..4d99b0a9021d4 100644 --- a/controller/proxy-injector/server_test.go +++ b/controller/proxy-injector/server_test.go @@ -2,7 +2,6 @@ package injector import ( "bytes" - "fmt" "io/ioutil" "net/http" "net/http/httptest" @@ -92,7 +91,7 @@ func TestNewWebhookServer(t *testing.T) { t.Fatal("Unexpected error: ", err) } - if server.Addr != fmt.Sprintf("%s", addr) { + if server.Addr != addr { t.Errorf("Expected server address to be :%q", addr) } } diff --git a/testutil/kubernetes_helper.go b/testutil/kubernetes_helper.go index 6a2cd8200279b..b253355df7447 100644 --- a/testutil/kubernetes_helper.go +++ b/testutil/kubernetes_helper.go @@ -195,7 +195,7 @@ func (h *KubernetesHelper) GetPodsForDeployment(namespace string, deploymentName // that's in the format namespace/resource. If the strings is in a different // format it returns an error. func (h *KubernetesHelper) ParseNamespacedResource(resource string) (string, string, error) { - r := regexp.MustCompile("^(.+)\\/(.+)$") + r := regexp.MustCompile(`^(.+)\/(.+)$`) matches := r.FindAllStringSubmatch(resource, 2) if len(matches) == 0 { return "", "", fmt.Errorf("string [%s] didn't contain expected format for namespace/resource, extracted: %v", resource, matches) diff --git a/web/srv/api_handlers.go b/web/srv/api_handlers.go index e60b5c19cbc03..445fd3c62d2ff 100644 --- a/web/srv/api_handlers.go +++ b/web/srv/api_handlers.go @@ -236,7 +236,7 @@ func (h *handler) handleAPITap(w http.ResponseWriter, req *http.Request, p httpr break } - if err := ws.WriteMessage(websocket.TextMessage, []byte(buf.String())); err != nil { + if err := ws.WriteMessage(websocket.TextMessage, buf.Bytes()); err != nil { if websocket.IsUnexpectedCloseError(err, websocket.CloseNormalClosure) { log.Error(err) }