From 6d6afb454a4e2f1feca9c025ed24a14bcdadd729 Mon Sep 17 00:00:00 2001 From: Erik Geiser Date: Sat, 7 Nov 2020 13:01:10 +0100 Subject: [PATCH] ci: Add golangci-lint. --- .github/workflows/build.yml | 7 ++++++ .golangci.yml | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .golangci.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7263090..ab4c7ba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,9 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 + - name: "Install golangci-lint" + run: | + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $HOME/bin latest - name: Set up Go uses: actions/setup-go@v2 with: @@ -29,6 +32,10 @@ jobs: ${{ runner.os }}-go- - name: Dependencies run: go mod tidy + - name: "Run golangci-lint" + run: | + export PATH=$HOME/bin:$PATH + golangci-lint run - name: Test run: go test -v -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt ./... - name: Upload coverage diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..53d8619 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,43 @@ +linters: + enable-all: true + disable: + - godox + - wsl + - gomnd + - testpackage + - nolintlint + - gofumpt + - nlreturn + - gci +linters-settings: + maligned: + # print struct with more effective memory layout or not, false by default + suggest-new: true + gocyclo: + # minimal code complexity to report, 30 by default (but we recommend 10-20) + min-complexity: 30 + goimports: + # put imports beginning with prefix after 3rd-party packages; + # it's a comma-separated list of prefixes + local-prefixes: github.com/goreleaser/fileglob + govet: + check-shadowing: true + errcheck: + ignore: ^Close.*,fmt:.*,github.com/pkg/errors:^Wrap.*,os:^Setenv$ + lll: + line-length: 200 + golint: + min-confidence: .8 + nakedret: + max-func-lines: 0 + gocritic: + disabled-checks: + - whyNoLint + enabled-tags: + - style + - performance +issues: + exclude-rules: + - text: "G104" # gosec G104 is caught by errcheck + linters: + - gosec