From 305fb0547d6be967df4145f0da7d0d2d411fe72c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Fri, 9 Jul 2021 17:18:08 +0200 Subject: [PATCH] virtcontainers: Fix `gosimple` issue on client.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some reason our static check started to get opinionated about code that's been there for ages. One of the suggestions is to improve: ``` INFO: Running golangci-lint on /home/fidencio/go/src/github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols/client client.go:431:2: S1017: should replace this `if` statement with an unconditional `strings.TrimPrefix` (gosimple) if strings.HasPrefix(sock, "mock:") { ``` And that's what this PR is about. Signed-off-by: Fabiano FidĂȘncio --- .../virtcontainers/pkg/agent/protocols/client/client.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/runtime/virtcontainers/pkg/agent/protocols/client/client.go b/src/runtime/virtcontainers/pkg/agent/protocols/client/client.go index 362dca0ad2..86a1943ceb 100644 --- a/src/runtime/virtcontainers/pkg/agent/protocols/client/client.go +++ b/src/runtime/virtcontainers/pkg/agent/protocols/client/client.go @@ -428,9 +428,7 @@ func HybridVSockDialer(sock string, timeout time.Duration) (net.Conn, error) { // just for tests use. func MockHybridVSockDialer(sock string, timeout time.Duration) (net.Conn, error) { - if strings.HasPrefix(sock, "mock:") { - sock = strings.TrimPrefix(sock, "mock:") - } + sock = strings.TrimPrefix(sock, "mock:") dialFunc := func() (net.Conn, error) { return net.DialTimeout("unix", sock, timeout)