From c3e7356903d1f9fc77c1cc2a700e127edcafeee8 Mon Sep 17 00:00:00 2001 From: Daisuke Maki Date: Mon, 1 Feb 2021 06:37:26 +0900 Subject: [PATCH 1/7] Add a golangci-lint Github Action The go vet is appended, because I have seen some important lint issues that are disabled by golangci-lint being reported by the vanilla go vet commnand --- .github/workflows/lint.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..283f40c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,14 @@ +name: lint +on: [push] +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: golangci/golangci-lint-action@v2 + with: + version: v1.34.1 + - name: Run go vet + run: | + go vet ./... From 21932ab583c30e04f29b76c81e67766d4dd5b15b Mon Sep 17 00:00:00 2001 From: Daisuke Maki Date: Mon, 1 Feb 2021 12:12:22 +0900 Subject: [PATCH 2/7] Add a config file --- .golangci.yml | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..634e501 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,57 @@ +run: + +linters-settings: + govet: + enable-all: true + disable: + - shadow + +linters: + enable-all: true + disable: + - dupl + - exhaustive + - exhaustivestruct + - errorlint + - funlen + - gci + - gochecknoglobals + - gochecknoinits + - gocognit + - gocritic + - gocyclo + - godot + - godox + - goerr113 + - gofumpt + - gomnd + - gosec + - lll + - makezero + - nakedret + - nestif + - nlreturn + - paralleltest + - testpackage + - thelper + - wrapcheck + - wsl + +issues: + exclude-rules: + # not needed + - path: /*.go + text: "ST1003: should not use underscores in package names" + linters: + - stylecheck + - path: /*.go + text: "don't use an underscore in package name" + linters: + - golint + + # Maximum issues count per one linter. Set to 0 to disable. Default is 50. + max-issues-per-linter: 0 + + # Maximum count of issues with the same text. Set to 0 to disable. Default is 3. + max-same-issues: 0 + From aeefd45f3314cf26a952efc69aebbb235842bfa4 Mon Sep 17 00:00:00 2001 From: Daisuke Maki Date: Mon, 1 Feb 2021 12:17:18 +0900 Subject: [PATCH 3/7] it might be better if we enable this for pull_requests too --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 283f40c..31b451c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,5 +1,5 @@ name: lint -on: [push] +on: [pull_request, push] jobs: golangci: name: lint From 0ac7b139e6bdf9778d8ff322a173e44bd28d574d Mon Sep 17 00:00:00 2001 From: Daisuke Maki Date: Mon, 1 Feb 2021 13:04:06 +0900 Subject: [PATCH 4/7] Add explicit 5m timeout --- .github/workflows/lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 31b451c..b6ecd2c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,6 +9,7 @@ jobs: - uses: golangci/golangci-lint-action@v2 with: version: v1.34.1 + args: --timeout=5m - name: Run go vet run: | go vet ./... From 5cd3291f16aa50c6bb8743f3278a2923ea57fa50 Mon Sep 17 00:00:00 2001 From: Daisuke Maki Date: Tue, 2 Feb 2021 07:57:27 +0900 Subject: [PATCH 5/7] Update golangci-lint --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b6ecd2c..15f06cd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,7 +8,7 @@ jobs: - uses: actions/checkout@v2 - uses: golangci/golangci-lint-action@v2 with: - version: v1.34.1 + version: v1.36.0 args: --timeout=5m - name: Run go vet run: | From 88ffc1673ef8d182e260bb115cdf555c40a22e34 Mon Sep 17 00:00:00 2001 From: Daisuke Maki Date: Tue, 2 Feb 2021 08:22:00 +0900 Subject: [PATCH 6/7] disable ifshort --- .golangci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.golangci.yml b/.golangci.yml index 0f95014..6bdcb8f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -30,6 +30,7 @@ linters: - gofumpt - gomnd - gosec + - ifshort - lll - makezero - nakedret From 2db3ac841b8144f351dbd1b29933f20f30714953 Mon Sep 17 00:00:00 2001 From: Daisuke Maki Date: Mon, 8 Feb 2021 14:14:28 +0900 Subject: [PATCH 7/7] remove go vet --- .github/workflows/lint.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 15f06cd..90644c7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,6 +10,3 @@ jobs: with: version: v1.36.0 args: --timeout=5m - - name: Run go vet - run: | - go vet ./...