-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update linter and fix found issues (#36)
- Loading branch information
1 parent
5816c6b
commit 653fa9d
Showing
3 changed files
with
129 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
- main | ||
|
||
env: | ||
GO_VERSION: '1.20' | ||
LINT_VERSION: '1.51.1' | ||
GO_VERSION: "1.20" | ||
LINT_VERSION: "1.55.2" | ||
|
||
name: CI | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }}.x | ||
- name: Run linters | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
# Required: the version of golangci-lint is required and must be specified without patch version: they always use the latest patch version. | ||
version: v${{ env.LINT_VERSION }} | ||
# enable gofmt to check formatting issues | ||
args: --enable gofmt | ||
# show only new issues if it's a pull request. The default value is `false`. | ||
only-new-issues: true | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }}.x | ||
- name: Run linters | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
# Required: the version of golangci-lint is required and must be specified without patch version: they always use the latest patch version. | ||
version: v${{ env.LINT_VERSION }} | ||
# enable gofmt to check formatting issues | ||
args: --enable gofmt | ||
# show only new issues if it's a pull request. The default value is `false`. | ||
only-new-issues: true | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }}.x | ||
- name: Run tests | ||
run: go test -count=1 ./... | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Install Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ env.GO_VERSION }}.x | ||
- name: Run tests | ||
run: go test -count=1 ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
run: | ||
tests: false | ||
|
||
issues: | ||
exclude-use-default: false | ||
|
||
linters: | ||
enable: | ||
- bodyclose | ||
- errcheck | ||
- goconst | ||
- gocritic | ||
- gofmt | ||
- goimports | ||
- revive | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- misspell | ||
- nakedret | ||
- staticcheck | ||
- typecheck | ||
- unused | ||
- errorlint | ||
- forcetypeassert | ||
- nlreturn | ||
- unconvert | ||
- unparam | ||
- gocyclo | ||
- gocognit | ||
- dogsled | ||
- dupl | ||
- errname | ||
- exhaustive | ||
- exportloopref | ||
- whitespace | ||
- rowserrcheck | ||
- reassign | ||
- prealloc | ||
|
||
linters-settings: | ||
revive: | ||
severity: warning | ||
confidence: 0.8 | ||
rules: | ||
- name: blank-imports | ||
- name: context-as-argument | ||
- name: context-keys-type | ||
- name: dot-imports | ||
- name: error-return | ||
- name: error-strings | ||
- name: error-naming | ||
- name: if-return | ||
- name: increment-decrement | ||
- name: var-naming | ||
- name: var-declaration | ||
- name: range | ||
- name: receiver-naming | ||
- name: time-naming | ||
- name: unexported-return | ||
- name: indent-error-flow | ||
- name: errorf | ||
- name: empty-block | ||
- name: superfluous-else | ||
- name: unused-parameter | ||
- name: unreachable-code | ||
- name: redefines-builtin-id | ||
- name: exported | ||
- name: range-val-in-closure | ||
- name: range-val-address | ||
- name: datarace | ||
nlreturn: | ||
block-size: 2 | ||
errcheck: | ||
ignore: ((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.) | ||
exclude-functions: | ||
- (*database/sql.Rows).Close | ||
gosec: | ||
excludes: # Duplicated errcheck checks | ||
- G104 # Audit errors not checked | ||
# - G307 # Deferring a method which returns an error | ||
# goconst: | ||
# # Minimum occurrences of constant string count to trigger issue. | ||
# min-occurrences: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters