From 74828677e08a79df24a1a1958e5f8e84d7ef4646 Mon Sep 17 00:00:00 2001 From: Pascal Bourdier Date: Tue, 17 Dec 2024 20:38:42 +0100 Subject: [PATCH] ci: enable gocritic in golangci (#1223) --- .golangci.yml | 3 +++ app/app.go | 3 +-- environment/container/docker/daemon.go | 6 +++--- environment/container/kubernetes/kubernetes.go | 4 +--- util/terminal/output.go | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index e69de29bb..782035985 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -0,0 +1,3 @@ +linters: + enable: + - gocritic diff --git a/app/app.go b/app/app.go index 499614f26..c5bf56168 100644 --- a/app/app.go +++ b/app/app.go @@ -407,8 +407,7 @@ func (c colimaApp) Version() error { var kube environment.Container for _, cont := range containerRuntimes { - switch cont.Name() { - case kubernetes.Name: + if cont.Name() == kubernetes.Name { kube = cont continue } diff --git a/environment/container/docker/daemon.go b/environment/container/docker/daemon.go index a9d3026a6..360329760 100644 --- a/environment/container/docker/daemon.go +++ b/environment/container/docker/daemon.go @@ -58,13 +58,13 @@ func (d dockerRuntime) createDaemonFile(conf map[string]any, env map[string]stri return err } if vars.http != "" { - proxyConf["http-proxy"] = strings.Replace(vars.http, "127.0.0.1", hostGatewayIP, -1) + proxyConf["http-proxy"] = strings.ReplaceAll(vars.http, "127.0.0.1", hostGatewayIP) } if vars.https != "" { - proxyConf["https-proxy"] = strings.Replace(vars.https, "127.0.0.1", hostGatewayIP, -1) + proxyConf["https-proxy"] = strings.ReplaceAll(vars.https, "127.0.0.1", hostGatewayIP) } if vars.no != "" { - proxyConf["no-proxy"] = strings.Replace(vars.no, "127.0.0.1", hostGatewayIP, -1) + proxyConf["no-proxy"] = strings.ReplaceAll(vars.no, "127.0.0.1", hostGatewayIP) } conf["proxies"] = proxyConf } diff --git a/environment/container/kubernetes/kubernetes.go b/environment/container/kubernetes/kubernetes.go index 6baa27e3a..d6b983201 100644 --- a/environment/container/kubernetes/kubernetes.go +++ b/environment/container/kubernetes/kubernetes.go @@ -246,9 +246,7 @@ func (c kubernetesRuntime) Teardown(ctx context.Context) error { // k3s is buggy with external containerd for now // cleanup is manual - a.Add(func() error { - return c.deleteAllContainers() - }) + a.Add(c.deleteAllContainers) c.teardownKubeconfig(a) diff --git a/util/terminal/output.go b/util/terminal/output.go index 55f8742af..86c8587d7 100644 --- a/util/terminal/output.go +++ b/util/terminal/output.go @@ -66,7 +66,7 @@ func (v *verboseWriter) refresh() error { } func (v *verboseWriter) addLine() { - defer v.buf.Truncate(0) + defer v.buf.Reset() // if height <=0, do not scroll if v.lineHeight <= 0 {