From f5a1707d3c007a4f3c229527d34cdbf1300492a4 Mon Sep 17 00:00:00 2001 From: Mitsuo Heijo Date: Tue, 17 Nov 2020 23:08:15 +0900 Subject: [PATCH] Update golangci-lint to v1.32 --- .github/workflows/go.yml | 2 +- .golangci.yml | 3 +++ .travis.yml | 2 +- internal/proto/scan.go | 2 +- internal/util.go | 10 ---------- options.go | 2 +- redis.go | 3 ++- 7 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 43ceded..6ce6e28 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -45,6 +45,6 @@ jobs: fi - name: Install golangci run: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.31.0 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.32.2 - name: Test run: make diff --git a/.golangci.yml b/.golangci.yml index 1e8d238..b88b2b9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -19,3 +19,6 @@ linters: - exhaustive - nestif - nlreturn + - exhaustivestruct + - wrapcheck + - errorlint diff --git a/.travis.yml b/.travis.yml index 1bf578d..a221d84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,4 +17,4 @@ go_import_path: github.com/go-redis/redis before_install: - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- - -b $(go env GOPATH)/bin v1.31.0 + -b $(go env GOPATH)/bin v1.32.2 diff --git a/internal/proto/scan.go b/internal/proto/scan.go index 08d18d3..c2c3ed1 100644 --- a/internal/proto/scan.go +++ b/internal/proto/scan.go @@ -131,7 +131,7 @@ func ScanSlice(data []string, slice interface{}) error { for i, s := range data { elem := next() if err := Scan([]byte(s), elem.Addr().Interface()); err != nil { - err = fmt.Errorf("redis: ScanSlice index=%d value=%q failed: %s", i, s, err) + err = fmt.Errorf("redis: ScanSlice index=%d value=%q failed: %w", i, s, err) return err } } diff --git a/internal/util.go b/internal/util.go index 894382b..30050ff 100644 --- a/internal/util.go +++ b/internal/util.go @@ -50,16 +50,6 @@ func isLower(s string) bool { return true } -func Unwrap(err error) error { - u, ok := err.(interface { - Unwrap() error - }) - if !ok { - return nil - } - return u.Unwrap() -} - //------------------------------------------------------------------------------ func WithSpan(ctx context.Context, name string, fn func(context.Context, trace.Span) error) error { diff --git a/options.go b/options.go index f2c16c5..1fd5e16 100644 --- a/options.go +++ b/options.go @@ -271,7 +271,7 @@ func setupUnixConn(u *url.URL) (*Options, error) { db, err := strconv.Atoi(dbStr) if err != nil { - return nil, fmt.Errorf("redis: invalid database number: %s", err) + return nil, fmt.Errorf("redis: invalid database number: %w", err) } o.DB = db diff --git a/redis.go b/redis.go index efad7f1..0ff401e 100644 --- a/redis.go +++ b/redis.go @@ -2,6 +2,7 @@ package redis import ( "context" + "errors" "fmt" "time" @@ -230,7 +231,7 @@ func (c *baseClient) _getConn(ctx context.Context) (*pool.Conn, error) { }) if err != nil { c.connPool.Remove(ctx, cn, err) - if err := internal.Unwrap(err); err != nil { + if err := errors.Unwrap(err); err != nil { return nil, err } return nil, err