From 0d28e293355804331be686f4a58e3899690d12dc Mon Sep 17 00:00:00 2001 From: David Bariod Date: Fri, 6 Nov 2020 13:13:37 +0100 Subject: [PATCH 1/4] bump golang versions in travis ci --- .travis.yml | 2 +- travis/lint.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5e20aa4..b941b17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ git: depth: 1 env: - GO111MODULE=on -go: [1.13.x, 1.14.x] +go: [1.14.x, 1.15.x] os: [linux, osx] install: - ./travis/install.sh diff --git a/travis/lint.sh b/travis/lint.sh index 0ed1d7c..c0a42df 100755 --- a/travis/lint.sh +++ b/travis/lint.sh @@ -2,4 +2,6 @@ if [[ "$TRAVIS_GO_VERSION" =~ ^1\.13\. ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$GO111MODULE" == "on" ]]; then $(go env GOPATH)/bin/golangci-lint run ./... +else + echo "linter has not been run" fi From 581900062e0cbb42edecd4524ecbe95d447aff04 Mon Sep 17 00:00:00 2001 From: David Bariod Date: Fri, 6 Nov 2020 13:26:15 +0100 Subject: [PATCH 2/4] bump golangci-lint version --- .travis.yml | 4 ++-- travis/install.sh | 11 +++-------- travis/lint.sh | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index b941b17..996f57a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,8 @@ git: depth: 1 env: - GO111MODULE=on -go: [1.14.x, 1.15.x] -os: [linux, osx] +go: 1.15.x +os: linux install: - ./travis/install.sh script: diff --git a/travis/install.sh b/travis/install.sh index 5fc40dd..8cbd0d7 100755 --- a/travis/install.sh +++ b/travis/install.sh @@ -2,9 +2,9 @@ set -e -# Install golanci 1.21.0 -if [[ "$TRAVIS_GO_VERSION" =~ ^1\.13\. ]]; then - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.21.0 +# Install golanci 1.32.2 +if [[ "$TRAVIS_GO_VERSION" =~ ^1\.15\. ]]; then + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.32.2 fi # Only do this for go1.12 when modules are on so that it doesn't need to be done when modules are off as well. @@ -15,8 +15,3 @@ fi if [[ "$GO111MODULE" == "on" ]]; then go mod download fi - -if [[ "$GO111MODULE" == "off" ]]; then - # Should contain all regular (not indirect) modules from go.mod - go get github.com/stretchr/testify golang.org/x/sys/unix golang.org/x/sys/windows -fi diff --git a/travis/lint.sh b/travis/lint.sh index c0a42df..98fb5bb 100755 --- a/travis/lint.sh +++ b/travis/lint.sh @@ -1,6 +1,6 @@ #!/bin/bash -if [[ "$TRAVIS_GO_VERSION" =~ ^1\.13\. ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$GO111MODULE" == "on" ]]; then +if [[ "$TRAVIS_GO_VERSION" =~ ^1\.15\. ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$GO111MODULE" == "on" ]]; then $(go env GOPATH)/bin/golangci-lint run ./... else echo "linter has not been run" From e328a4e3f43df37e6139f62da7c0e857072ce84c Mon Sep 17 00:00:00 2001 From: David Bariod Date: Sun, 8 Nov 2020 07:07:05 +0100 Subject: [PATCH 3/4] fix linter errors --- entry.go | 6 ++---- text_formatter.go | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/entry.go b/entry.go index 5a5cbfe..2e87f5f 100644 --- a/entry.go +++ b/entry.go @@ -123,11 +123,9 @@ func (entry *Entry) WithFields(fields Fields) *Entry { for k, v := range fields { isErrField := false if t := reflect.TypeOf(v); t != nil { - switch t.Kind() { - case reflect.Func: + switch { + case t.Kind() == reflect.Func, t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Func: isErrField = true - case reflect.Ptr: - isErrField = t.Elem().Kind() == reflect.Func } } if isErrField { diff --git a/text_formatter.go b/text_formatter.go index 3c28b54..8fc698a 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -235,6 +235,8 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []strin levelColor = yellow case ErrorLevel, FatalLevel, PanicLevel: levelColor = red + case InfoLevel: + levelColor = blue default: levelColor = blue } From 89b92b94ddc015302eb71851f7c1650a828c31bb Mon Sep 17 00:00:00 2001 From: David Bariod Date: Sun, 8 Nov 2020 07:19:28 +0100 Subject: [PATCH 4/4] one more linter error fixed --- json_formatter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json_formatter.go b/json_formatter.go index ba7f237..afaf0fc 100644 --- a/json_formatter.go +++ b/json_formatter.go @@ -118,7 +118,7 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { encoder.SetIndent("", " ") } if err := encoder.Encode(data); err != nil { - return nil, fmt.Errorf("failed to marshal fields to JSON, %v", err) + return nil, fmt.Errorf("failed to marshal fields to JSON, %w", err) } return b.Bytes(), nil