From 6e71054267e1eb24fc4cbacf04283d52a973bc2b Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Fri, 20 Aug 2021 20:52:34 +0200 Subject: [PATCH] extend lint checking This is the lint.yaml from logr with better GitHub integration and more checks enabled. --- .github/workflows/lint.yaml | 46 ++++++++++++++++++++++++------------- example/main.go | 10 ++++---- zapr.go | 2 +- 3 files changed, 36 insertions(+), 22 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 5c84b2d..d76ae31 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -6,23 +6,37 @@ jobs: lint: runs-on: ubuntu-latest steps: - - name: Install Go - uses: actions/setup-go@v2 - name: Checkout code uses: actions/checkout@v2 - name: Lint - run: | - docker run --rm -v `pwd`:/go/src/prj -w /go/src/prj \ - golangci/golangci-lint golangci-lint run \ - -v \ - --disable-all \ - -E deadcode \ - -E gocritic \ - -E gofmt \ - -E govet \ - -E ineffassign \ - -E misspell \ - -E revive \ - -E staticcheck \ - -E unused \ + uses: golangci/golangci-lint-action@v2 + with: + # version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: latest + + # Optional: show only new issues if it's a pull request. The default value is `false`. + # only-new-issues: true + + # golangci-lint command line arguments. + args: + -v + --max-same-issues 10 + --disable-all + --exclude-use-default=false + -E asciicheck + -E deadcode + -E errcheck + -E forcetypeassert + -E gocritic + -E gofmt + -E goimports + -E gosimple + -E govet + -E ineffassign + -E misspell + -E revive + -E staticcheck + -E structcheck + -E typecheck + -E unused -E varcheck diff --git a/example/main.go b/example/main.go index 23c1d9e..b45a396 100644 --- a/example/main.go +++ b/example/main.go @@ -22,15 +22,15 @@ import ( "go.uber.org/zap" ) -type E struct { +type e struct { str string } -func (e E) Error() string { +func (e e) Error() string { return e.str } -func Helper(log logr.Logger, msg string) { +func helper(log logr.Logger, msg string) { helper2(log, msg) } @@ -54,6 +54,6 @@ func example(log logr.Logger) { log.V(1).Info("you should see this") log.V(1).V(1).Info("you should NOT see this") log.Error(nil, "uh oh", "trouble", true, "reasons", []float64{0.1, 0.11, 3.14}) - log.Error(E{"an error occurred"}, "goodbye", "code", -1) - Helper(log, "thru a helper") + log.Error(e{"an error occurred"}, "goodbye", "code", -1) + helper(log, "thru a helper") } diff --git a/zapr.go b/zapr.go index 29799e7..57c2028 100644 --- a/zapr.go +++ b/zapr.go @@ -28,7 +28,7 @@ limitations under the License. // See the License for the specific language governing permissions and // limitations under the License. -// package zapr defines an implementation of the github.com/go-logr/logr +// Package zapr defines an implementation of the github.com/go-logr/logr // interfaces built on top of Zap (go.uber.org/zap). // // Usage