From 7a678f24e0560ac70db7ff4be978235e323a30ba Mon Sep 17 00:00:00 2001 From: Alexander Adhyatma Date: Sat, 29 May 2021 14:27:54 +0700 Subject: [PATCH] change deprecated golint to its successor, revive --- .golangci.yml | 2 +- internal/vpn/client.go | 6 +----- pkg/router/route_group.go | 6 +----- pkg/setup/setupclient/client.go | 6 +----- pkg/snet/directtp/client.go | 6 +----- pkg/util/pathutil/util.go | 6 +----- 6 files changed, 6 insertions(+), 26 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index b1e5a2eef2..f83a369b7f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -151,7 +151,7 @@ linters-settings: linters: enable: - - golint + - revive - goimports - varcheck - unparam diff --git a/internal/vpn/client.go b/internal/vpn/client.go index d1e2eca33c..b4711da66c 100644 --- a/internal/vpn/client.go +++ b/internal/vpn/client.go @@ -235,11 +235,7 @@ func (c *Client) AddDirectRoute(ip net.IP) error { } defer c.releaseSysPrivileges() - if err := c.setupDirectRoute(ip); err != nil { - return err - } - - return nil + return c.setupDirectRoute(ip) } // RemoveDirectRoute removes direct route. Packets destined to `ip` will diff --git a/pkg/router/route_group.go b/pkg/router/route_group.go index 882a51b987..874f573a37 100644 --- a/pkg/router/route_group.go +++ b/pkg/router/route_group.go @@ -428,11 +428,7 @@ func (rg *RouteGroup) sendNetworkProbe() error { packet := routing.MakeNetworkProbePacket(rule.NextRouteID(), timestamp, throughput) - if err := rg.writePacket(context.Background(), tp, packet, rule.KeyRouteID()); err != nil { - return err - } - - return nil + return rg.writePacket(context.Background(), tp, packet, rule.KeyRouteID()) } func (rg *RouteGroup) networkProbeServiceFn(_ time.Duration) { diff --git a/pkg/setup/setupclient/client.go b/pkg/setup/setupclient/client.go index 5c3b13c84f..86e319b4a3 100644 --- a/pkg/setup/setupclient/client.go +++ b/pkg/setup/setupclient/client.go @@ -69,11 +69,7 @@ func (c *Client) Close() error { return err } - if err := c.conn.Close(); err != nil { - return err - } - - return nil + return c.conn.Close() } // DialRouteGroup generates rules for routes from a visor and sends them to visors. diff --git a/pkg/snet/directtp/client.go b/pkg/snet/directtp/client.go index 34385450b7..30764e38af 100644 --- a/pkg/snet/directtp/client.go +++ b/pkg/snet/directtp/client.go @@ -230,11 +230,7 @@ func (c *client) acceptConn() error { return err } - if err := lis.Introduce(wrappedConn); err != nil { - return err - } - - return nil + return lis.Introduce(wrappedConn) } // Dial dials a new Conn to specified remote public key and port. diff --git a/pkg/util/pathutil/util.go b/pkg/util/pathutil/util.go index aed48e6e92..5ad34723fd 100644 --- a/pkg/util/pathutil/util.go +++ b/pkg/util/pathutil/util.go @@ -45,11 +45,7 @@ func AtomicWriteFile(filename string, data []byte) error { return err } - if err := rename.Rename(tempFilePath, filename); err != nil { - return err - } - - return nil + return rename.Rename(tempFilePath, filename) } // AtomicAppendToFile calls AtomicWriteFile but appends new data to destiny file