Update linter configuration

This commit is contained in:
世界 2024-09-14 14:40:11 +08:00
parent aaaacba916
commit f845cffeac
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
5 changed files with 54 additions and 36 deletions

View file

@ -1,4 +1,4 @@
name: Lint name: lint
on: on:
push: push:
@ -24,16 +24,17 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v4 uses: actions/setup-go@v5
with: with:
go-version: ^1.22 go-version: ^1.23
- name: Cache go module - name: Cache go module
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: | path: |
~/go/pkg/mod ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }} key: go-${{ hashFiles('**/go.sum') }}
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@v3 uses: golangci/golangci-lint-action@v6
with: with:
version: latest version: latest
args: .

View file

@ -1,4 +1,4 @@
name: Debug build name: test
on: on:
push: push:
@ -16,7 +16,7 @@ on:
jobs: jobs:
build: build:
name: Linux Debug build name: Linux
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@ -24,14 +24,14 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v4 uses: actions/setup-go@v5
with: with:
go-version: ^1.22 go-version: ^1.23
- name: Build - name: Build
run: | run: |
make test make test
build_go120: build_go120:
name: Linux Debug build (Go 1.20) name: Linux (Go 1.20)
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@ -39,7 +39,7 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v4 uses: actions/setup-go@v5
with: with:
go-version: ~1.20 go-version: ~1.20
continue-on-error: true continue-on-error: true
@ -47,7 +47,7 @@ jobs:
run: | run: |
make test make test
build_go121: build_go121:
name: Linux Debug build (Go 1.21) name: Linux (Go 1.21)
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
@ -55,15 +55,31 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v4 uses: actions/setup-go@v5
with: with:
go-version: ~1.21 go-version: ~1.21
continue-on-error: true continue-on-error: true
- name: Build - name: Build
run: | run: |
make test make test
build__windows: build_go122:
name: Windows Debug build name: Linux (Go 1.22)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ~1.22
continue-on-error: true
- name: Build
run: |
make test
build_windows:
name: Windows
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Checkout - name: Checkout
@ -71,15 +87,15 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v4 uses: actions/setup-go@v5
with: with:
go-version: ^1.22 go-version: ^1.23
continue-on-error: true continue-on-error: true
- name: Build - name: Build
run: | run: |
make test make test
build_darwin: build_darwin:
name: macOS Debug build name: macOS
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- name: Checkout - name: Checkout
@ -87,9 +103,9 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Setup Go - name: Setup Go
uses: actions/setup-go@v4 uses: actions/setup-go@v5
with: with:
go-version: ^1.22 go-version: ^1.23
continue-on-error: true continue-on-error: true
- name: Build - name: Build
run: | run: |

View file

@ -3,18 +3,18 @@ linters:
enable: enable:
- gofumpt - gofumpt
- govet - govet
# - gci - gci
- staticcheck - staticcheck
- paralleltest
issues: - ineffassign
exclude-dirs:
- internal
linters-settings: linters-settings:
# gci: gci:
# sections: custom-order: true
# - standard sections:
# - prefix(github.com/sagernet/sing) - standard
# - default - prefix(github.com/sagernet/)
staticcheck: - default
go: '1.19'
run:
go: "1.23"

View file

@ -27,4 +27,5 @@ lint_install:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
test: test:
go test -v . go build -v .
#go test -v .

View file

@ -712,7 +712,7 @@ func (t *NativeTun) rules() []*netlink.Rule {
it.Family = unix.AF_INET it.Family = unix.AF_INET
rules = append(rules, it) rules = append(rules, it)
} }
priority++ // priority++
} }
if p6 { if p6 {
it = netlink.NewRule() it = netlink.NewRule()
@ -755,7 +755,7 @@ func (t *NativeTun) rules() []*netlink.Rule {
it.Table = t.options.IPRoute2TableIndex it.Table = t.options.IPRoute2TableIndex
it.Family = unix.AF_INET6 it.Family = unix.AF_INET6
rules = append(rules, it) rules = append(rules, it)
priority6++ // priority6++
} }
if p4 { if p4 {
it = netlink.NewRule() it = netlink.NewRule()