Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

migrate to golangci-lint v2 (#13109)

Michael Yang718961de68fb
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 82f2b0403..08a0a7143 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -226,12 +226,9 @@ jobs:
if: always()
run: go test -count=1 -benchtime=1x ./...
- # TODO(bmizerany): replace this heavy tool with just the
- # tools/checks/binaries we want and then make them all run in parallel
- # across jobs, not on a single tiny vm on Github Actions.
- - uses: golangci/golangci-lint-action@v6
+ - uses: golangci/golangci-lint-action@v9
with:
- args: --timeout 10m0s -v
+ only-new-issues: true
patches:
runs-on: ubuntu-latest
@@ -240,4 +237,4 @@ jobs:
- name: Verify patches apply cleanly and do not change files
run: |
make -f Makefile.sync clean checkout apply-patches sync
- git diff --compact-summary --exit-code
\ No newline at end of file
+ git diff --compact-summary --exit-code
diff --git a/.golangci.yaml b/.golangci.yaml
index 9d6705bd3..b211e5de7 100644
--- a/.golangci.yaml
+++ b/.golangci.yaml
@@ -1,41 +1,77 @@
-run:
- timeout: 5m
+version: "2"
linters:
+ default: none
enable:
- asasalint
- bidichk
- bodyclose
- containedctx
+ - copyloopvar
+ - errcheck
+ - errorlint
+ - exptostd
- gocheckcompilerdirectives
- - gofmt
- - gofumpt
- - gosimple
+ - gocritic
- govet
- ineffassign
- intrange
- makezero
- misspell
+ - modernize
- nilerr
+ - nilnil
- nolintlint
- nosprintfhostport
+ - perfsprint
+ - prealloc
+ - sloglint
- staticcheck
- unconvert
+ - unused
+ - usestdlibvars
- usetesting
- wastedassign
- whitespace
- disable:
- - usestdlibvars
- - errcheck
-linters-settings:
- staticcheck:
- checks:
- - all
- - -SA1019 # omit Deprecated check
-severity:
- default-severity: error
- rules:
- - linters:
- - gofmt
- - goimports
- - intrange
- severity: info
+ settings:
+ errcheck:
+ exclude-functions:
+ - fmt.Fprintf
+ perfsprint:
+ strconcat: false
+ concat-loop: false
+ staticcheck:
+ checks:
+ - all
+ # Using a deprecated function, variable, constant or field.
+ # https://staticcheck.dev/docs/checks/#SA1019
+ - -SA1019
+ # Incorrect or missing package comment.
+ # https://staticcheck.dev/docs/checks/#ST1000
+ - -ST1000
+ # Poorly chosen identifier.
+ # https://staticcheck.dev/docs/checks/#ST1003
+ - -ST1003
+ # The documentation of an exported function should start with the function's name.
+ # https://staticcheck.dev/docs/checks/#ST1020
+ - -ST1020
+ # The documentation of an exported type should start with type's name.
+ # https://staticcheck.dev/docs/checks/#ST1021
+ - -ST1021
+ # The documentation of an exported variable or constant should start with variable's name.
+ # https://staticcheck.dev/docs/checks/#ST1022
+ - -ST1022
+ usestdlibvars:
+ http-method: false
+ http-status-code: false
+
+formatters:
+ enable:
+ - gci
+ - gofmt
+ - gofumpt
+ settings:
+ gci:
+ sections:
+ - standard
+ - default
+ - localmodule
diff --git a/fs/ggml/gguf.go b/fs/ggml/gguf.go
index 9ee42e368..b694deadb 100644
--- a/fs/ggml/gguf.go
+++ b/fs/ggml/gguf.go
@@ -305,7 +305,7 @@ func readGGUFV1StringsData(llm *gguf, r io.Reader, a *array[string]) (any, error
a.values[i] = e
} else {
- discardGGUFString(llm, r)
+ _ = discardGGUFString(llm, r)
}
}
@@ -568,7 +568,6 @@ func WriteGGUF(f *os.File, kv KV, ts []*Tensor) error {
g.SetLimit(runtime.GOMAXPROCS(0))
// TODO consider reducing if tensors size * gomaxprocs is larger than free memory
for _, t := range ts {
- t := t
w := io.NewOffsetWriter(f, offset+int64(t.Offset))
g.Go(func() error {
_, err := t.WriteTo(w)
diff --git a/go.mod b/go.mod
index 54e7942cd..6e7dc1d6d 100644
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,6 @@ require (
github.com/x448/float16 v0.8.4
golang.org/x/sync v0.12.0
golang.org/x/sys v0.36.0
-
)
require (
diff --git a/ml/backend/ggml/ggml.go b/ml/backend/ggml/ggml.go
index 92ed44137..1413e044f 100644
--- a/ml/backend/ggml/ggml.go
+++ b/ml/backend/ggml/ggml.go
@@ -499,7 +499,6 @@ func (b *Backend) Load(ctx context.Context, progress func(float32)) error {
g, ctx := errgroup.WithContext(ctx)
g.SetLimit(runtime.GOMAXPROCS(0))
for _, t := range b.meta.Tensors().Items() {
- t := t
g.Go(func() error {
tts := make([]*C.struct_ggml_tensor, max(1, len(b.tensorLoadTargets[t.Name])))
for i := range tts {
diff --git a/server/quantization.go b/server/quantization.go
index 10175a351..b15451d7e 100644
--- a/server/quantization.go
+++ b/server/quantization.go
@@ -175,7 +175,6 @@ func quantize(in, out *os.File, orig *fsggml.GGML, newFileType fsggml.FileType,
origTensors := orig.Tensors().Items()
outputTensors := make([]*fsggml.Tensor, len(origTensors))
for i, tensor := range origTensors {
- tensor := tensor
newType := newType(tensor, kv, qs, newFileType)
newTensor := &fsggml.Tensor{
Name: tensor.Name,
diff --git a/template/template_test.go b/template/template_test.go
index 45101e5ae..74388d6ef 100644
--- a/template/template_test.go
+++ b/template/template_test.go
@@ -219,7 +219,6 @@ func TestParse(t *testing.T) {
}
for _, tt := range validCases {
- tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()