mirror of
https://github.com/fumiama/go-nd-portal.git
synced 2026-06-29 23:51:06 +08:00
feat: add lints
This commit is contained in:
42
.github/workflows/pull.yml
vendored
Normal file
42
.github/workflows/pull.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
name: PR检查
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [assigned, opened, synchronize, reopened]
|
||||||
|
jobs:
|
||||||
|
golangci:
|
||||||
|
name: lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@master
|
||||||
|
with:
|
||||||
|
go-version: "1.24"
|
||||||
|
|
||||||
|
- name: Check out code into the Go module directory
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
|
- name: Tidy Modules
|
||||||
|
run: go mod tidy
|
||||||
|
|
||||||
|
- name: golangci-lint
|
||||||
|
uses: golangci/golangci-lint-action@master
|
||||||
|
with:
|
||||||
|
# Optional: 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: working directory, useful for monorepos
|
||||||
|
# working-directory: somedir
|
||||||
|
|
||||||
|
# Optional: golangci-lint command line arguments.
|
||||||
|
# args: --issues-exit-code=0
|
||||||
|
|
||||||
|
# Optional: show only new issues if it's a pull request. The default value is `false`.
|
||||||
|
# only-new-issues: true
|
||||||
|
|
||||||
|
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
|
||||||
|
# skip-pkg-cache: true
|
||||||
|
|
||||||
|
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
|
||||||
|
# skip-build-cache: true
|
||||||
36
.github/workflows/push.yml
vendored
Normal file
36
.github/workflows/push.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
name: 推送检查
|
||||||
|
on: [ push ]
|
||||||
|
jobs:
|
||||||
|
golangci:
|
||||||
|
name: lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@master
|
||||||
|
with:
|
||||||
|
go-version: "1.24"
|
||||||
|
|
||||||
|
- name: Check out code into the Go module directory
|
||||||
|
uses: actions/checkout@master
|
||||||
|
|
||||||
|
- name: Tidy Modules
|
||||||
|
run: go mod tidy
|
||||||
|
|
||||||
|
- name: Run Lint
|
||||||
|
uses: golangci/golangci-lint-action@master
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
|
||||||
|
- name: Commit back
|
||||||
|
if: ${{ !github.head_ref }}
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
git config --local user.name 'github-actions[bot]'
|
||||||
|
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
|
||||||
|
git add --all
|
||||||
|
git commit -m "chore(lint): 改进代码样式"
|
||||||
|
|
||||||
|
- name: Create Pull Request
|
||||||
|
if: ${{ !github.head_ref }}
|
||||||
|
continue-on-error: true
|
||||||
|
uses: peter-evans/create-pull-request@v4
|
||||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.19
|
go-version: "1.24"
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|||||||
75
.golangci.yml
Normal file
75
.golangci.yml
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
linters-settings:
|
||||||
|
errcheck:
|
||||||
|
ignoretests: true
|
||||||
|
|
||||||
|
goimports:
|
||||||
|
local-prefixes: github.com/fumiama/go-nd-portal
|
||||||
|
|
||||||
|
forbidigo:
|
||||||
|
# Forbid the following identifiers
|
||||||
|
forbid:
|
||||||
|
- ^fmt\.Errorf$ # consider errors.Errorf in github.com/pkg/errors
|
||||||
|
|
||||||
|
linters:
|
||||||
|
# please, do not use `enable-all`: it's deprecated and will be removed soon.
|
||||||
|
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
|
||||||
|
disable-all: true
|
||||||
|
fast: false
|
||||||
|
enable:
|
||||||
|
- bodyclose
|
||||||
|
#- depguard
|
||||||
|
- dogsled
|
||||||
|
- errcheck
|
||||||
|
#- exportloopref
|
||||||
|
- exhaustive
|
||||||
|
#- funlen
|
||||||
|
#- goconst
|
||||||
|
- gocritic
|
||||||
|
#- gocyclo
|
||||||
|
- gofmt
|
||||||
|
- goimports
|
||||||
|
- goprintffuncname
|
||||||
|
#- gosec
|
||||||
|
- gosimple
|
||||||
|
- govet
|
||||||
|
- ineffassign
|
||||||
|
#- misspell
|
||||||
|
- nolintlint
|
||||||
|
- rowserrcheck
|
||||||
|
- staticcheck
|
||||||
|
- stylecheck
|
||||||
|
- typecheck
|
||||||
|
- unconvert
|
||||||
|
- unparam
|
||||||
|
- unused
|
||||||
|
- whitespace
|
||||||
|
- prealloc
|
||||||
|
- predeclared
|
||||||
|
- asciicheck
|
||||||
|
- revive
|
||||||
|
- forbidigo
|
||||||
|
- makezero
|
||||||
|
|
||||||
|
run:
|
||||||
|
# default concurrency is a available CPU number.
|
||||||
|
# concurrency: 4 # explicitly omit this value to fully utilize available resources.
|
||||||
|
deadline: 5m
|
||||||
|
issues-exit-code: 1
|
||||||
|
tests: false
|
||||||
|
go: '1.24'
|
||||||
|
|
||||||
|
# output configuration options
|
||||||
|
output:
|
||||||
|
formats:
|
||||||
|
- format: "colored-line-number"
|
||||||
|
print-issued-lines: true
|
||||||
|
print-linter-name: true
|
||||||
|
uniq-by-line: true
|
||||||
|
|
||||||
|
issues:
|
||||||
|
# Fix found issues (if it's supported by the linter)
|
||||||
|
fix: true
|
||||||
|
exclude-use-default: false
|
||||||
|
exclude:
|
||||||
|
- "Error return value of .((os.)?std(out|err)..*|.*Close|.*Seek|.*Flush|os.Remove(All)?|.*print(f|ln)?|os.(Un)?Setenv). is not check"
|
||||||
|
- 'identifier ".*" contain non-ASCII character: U\+.*'
|
||||||
Reference in New Issue
Block a user