mirror of https://github.com/ollama/ollama
migrate to golangci-lint v2 (#13109)
* migrate to golangci-lint v2 * copyloopvar
This commit is contained in:
parent
330f62a7fa
commit
718961de68
|
|
@ -226,12 +226,9 @@ jobs:
|
||||||
if: always()
|
if: always()
|
||||||
run: go test -count=1 -benchtime=1x ./...
|
run: go test -count=1 -benchtime=1x ./...
|
||||||
|
|
||||||
# TODO(bmizerany): replace this heavy tool with just the
|
- uses: golangci/golangci-lint-action@v9
|
||||||
# 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
|
|
||||||
with:
|
with:
|
||||||
args: --timeout 10m0s -v
|
only-new-issues: true
|
||||||
|
|
||||||
patches:
|
patches:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,77 @@
|
||||||
run:
|
version: "2"
|
||||||
timeout: 5m
|
|
||||||
linters:
|
linters:
|
||||||
|
default: none
|
||||||
enable:
|
enable:
|
||||||
- asasalint
|
- asasalint
|
||||||
- bidichk
|
- bidichk
|
||||||
- bodyclose
|
- bodyclose
|
||||||
- containedctx
|
- containedctx
|
||||||
|
- copyloopvar
|
||||||
|
- errcheck
|
||||||
|
- errorlint
|
||||||
|
- exptostd
|
||||||
- gocheckcompilerdirectives
|
- gocheckcompilerdirectives
|
||||||
- gofmt
|
- gocritic
|
||||||
- gofumpt
|
|
||||||
- gosimple
|
|
||||||
- govet
|
- govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- intrange
|
- intrange
|
||||||
- makezero
|
- makezero
|
||||||
- misspell
|
- misspell
|
||||||
|
- modernize
|
||||||
- nilerr
|
- nilerr
|
||||||
|
- nilnil
|
||||||
- nolintlint
|
- nolintlint
|
||||||
- nosprintfhostport
|
- nosprintfhostport
|
||||||
|
- perfsprint
|
||||||
|
- prealloc
|
||||||
|
- sloglint
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- unconvert
|
- unconvert
|
||||||
|
- unused
|
||||||
|
- usestdlibvars
|
||||||
- usetesting
|
- usetesting
|
||||||
- wastedassign
|
- wastedassign
|
||||||
- whitespace
|
- whitespace
|
||||||
disable:
|
settings:
|
||||||
- usestdlibvars
|
errcheck:
|
||||||
- errcheck
|
exclude-functions:
|
||||||
linters-settings:
|
- fmt.Fprintf
|
||||||
|
perfsprint:
|
||||||
|
strconcat: false
|
||||||
|
concat-loop: false
|
||||||
staticcheck:
|
staticcheck:
|
||||||
checks:
|
checks:
|
||||||
- all
|
- all
|
||||||
- -SA1019 # omit Deprecated check
|
# Using a deprecated function, variable, constant or field.
|
||||||
severity:
|
# https://staticcheck.dev/docs/checks/#SA1019
|
||||||
default-severity: error
|
- -SA1019
|
||||||
rules:
|
# Incorrect or missing package comment.
|
||||||
- linters:
|
# 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
|
- gofmt
|
||||||
- goimports
|
- gofumpt
|
||||||
- intrange
|
settings:
|
||||||
severity: info
|
gci:
|
||||||
|
sections:
|
||||||
|
- standard
|
||||||
|
- default
|
||||||
|
- localmodule
|
||||||
|
|
|
||||||
|
|
@ -305,7 +305,7 @@ func readGGUFV1StringsData(llm *gguf, r io.Reader, a *array[string]) (any, error
|
||||||
|
|
||||||
a.values[i] = e
|
a.values[i] = e
|
||||||
} else {
|
} 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))
|
g.SetLimit(runtime.GOMAXPROCS(0))
|
||||||
// TODO consider reducing if tensors size * gomaxprocs is larger than free memory
|
// TODO consider reducing if tensors size * gomaxprocs is larger than free memory
|
||||||
for _, t := range ts {
|
for _, t := range ts {
|
||||||
t := t
|
|
||||||
w := io.NewOffsetWriter(f, offset+int64(t.Offset))
|
w := io.NewOffsetWriter(f, offset+int64(t.Offset))
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
_, err := t.WriteTo(w)
|
_, err := t.WriteTo(w)
|
||||||
|
|
|
||||||
1
go.mod
1
go.mod
|
|
@ -17,7 +17,6 @@ require (
|
||||||
github.com/x448/float16 v0.8.4
|
github.com/x448/float16 v0.8.4
|
||||||
golang.org/x/sync v0.12.0
|
golang.org/x/sync v0.12.0
|
||||||
golang.org/x/sys v0.36.0
|
golang.org/x/sys v0.36.0
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|
|
||||||
|
|
@ -499,7 +499,6 @@ func (b *Backend) Load(ctx context.Context, progress func(float32)) error {
|
||||||
g, ctx := errgroup.WithContext(ctx)
|
g, ctx := errgroup.WithContext(ctx)
|
||||||
g.SetLimit(runtime.GOMAXPROCS(0))
|
g.SetLimit(runtime.GOMAXPROCS(0))
|
||||||
for _, t := range b.meta.Tensors().Items() {
|
for _, t := range b.meta.Tensors().Items() {
|
||||||
t := t
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
tts := make([]*C.struct_ggml_tensor, max(1, len(b.tensorLoadTargets[t.Name])))
|
tts := make([]*C.struct_ggml_tensor, max(1, len(b.tensorLoadTargets[t.Name])))
|
||||||
for i := range tts {
|
for i := range tts {
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,6 @@ func quantize(in, out *os.File, orig *fsggml.GGML, newFileType fsggml.FileType,
|
||||||
origTensors := orig.Tensors().Items()
|
origTensors := orig.Tensors().Items()
|
||||||
outputTensors := make([]*fsggml.Tensor, len(origTensors))
|
outputTensors := make([]*fsggml.Tensor, len(origTensors))
|
||||||
for i, tensor := range origTensors {
|
for i, tensor := range origTensors {
|
||||||
tensor := tensor
|
|
||||||
newType := newType(tensor, kv, qs, newFileType)
|
newType := newType(tensor, kv, qs, newFileType)
|
||||||
newTensor := &fsggml.Tensor{
|
newTensor := &fsggml.Tensor{
|
||||||
Name: tensor.Name,
|
Name: tensor.Name,
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,6 @@ func TestParse(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range validCases {
|
for _, tt := range validCases {
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue