From b42efe251683807d22f83c0213f51dabc2d72da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 22 Sep 2025 12:51:12 +0800 Subject: [PATCH] Update golangci-lint --- .github/workflows/lint.yml | 16 ++++----- .gitignore | 2 ++ .golangci.yml | 67 +++++++++++++++++++++++++++----------- tun_offload_linux.go | 6 ++-- 4 files changed, 59 insertions(+), 32 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c682b25..7d5cea8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,21 +20,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 with: fetch-depth: 0 - name: Setup Go uses: actions/setup-go@v5 with: - go-version: ^1.23 - - name: Cache go module - uses: actions/cache@v4 - with: - path: | - ~/go/pkg/mod - key: go-${{ hashFiles('**/go.sum') }} + go-version: ^1.25 - name: golangci-lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v8 with: version: latest - args: . \ No newline at end of file + args: --timeout=30m + install-mode: binary + verify: false \ No newline at end of file diff --git a/.gitignore b/.gitignore index f1298ea..3f3c51c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /.idea/ /vendor/ .DS_Store +!/README.md +/*.md diff --git a/.golangci.yml b/.golangci.yml index eecfec3..7a8a771 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,20 +1,49 @@ -linters: - disable-all: true - enable: - - gofumpt - - govet - - gci - - staticcheck - - paralleltest - - ineffassign - -linters-settings: - gci: - custom-order: true - sections: - - standard - - prefix(github.com/sagernet/) - - default - +version: "2" run: - go: "1.23" \ No newline at end of file + go: "1.25" +linters: + default: none + enable: + - govet + - ineffassign + - paralleltest + - staticcheck + settings: + staticcheck: + checks: + - all + - -S1000 + - -S1008 + - -S1017 + - -ST1003 + - -QF1001 + - -QF1003 + - -QF1008 + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gci + - gofumpt + settings: + gci: + sections: + - standard + - prefix(github.com/sagernet/) + - default + custom-order: true + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/tun_offload_linux.go b/tun_offload_linux.go index 7e44a55..7733760 100644 --- a/tun_offload_linux.go +++ b/tun_offload_linux.go @@ -149,12 +149,12 @@ func (t *tcpGROTable) insert(pkt []byte, srcAddrOffset, dstAddrOffset, tcphOffse } func (t *tcpGROTable) updateAt(item tcpGROItem, i int) { - items, _ := t.itemsByFlow[item.key] + items := t.itemsByFlow[item.key] items[i] = item } func (t *tcpGROTable) deleteAt(key tcpFlowKey, i int) { - items, _ := t.itemsByFlow[key] + items := t.itemsByFlow[key] items = append(items[:i], items[i+1:]...) t.itemsByFlow[key] = items } @@ -254,7 +254,7 @@ func (u *udpGROTable) insert(pkt []byte, srcAddrOffset, dstAddrOffset, udphOffse } func (u *udpGROTable) updateAt(item udpGROItem, i int) { - items, _ := u.itemsByFlow[item.key] + items := u.itemsByFlow[item.key] items[i] = item }