diff --git a/.github/workflows/golang.yml b/.github/workflows/golang.yml index b8f1222..7198f2f 100644 --- a/.github/workflows/golang.yml +++ b/.github/workflows/golang.yml @@ -40,7 +40,7 @@ jobs: with: go-version: ${{ env.GOLANG_VERSION }} - name: Lint - uses: golangci/golangci-lint-action@v6 + uses: golangci/golangci-lint-action@v8 with: version: latest args: -v --timeout 5m diff --git a/.golangci.yml b/.golangci.yml index 968affc..8d1f5f4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,35 +1,42 @@ -run: - deadline: 10m - +version: "2" linters: enable: - contextcheck - - errcheck - gocritic - - gofmt - - goimports - gosec - - gosimple - - govet - - ineffassign - misspell - - staticcheck - unconvert - - unused - -linters-settings: - goimports: - local-prefixes: github.com/NVIDIA/go-gpuallocator - -issues: - exclude-rules: - # We disable the memory aliasing checks in tests - - path: ".*_test.go" - linters: - - gosec - text: "G601: Implicit memory aliasing in for loop" - # We create world-readable files in tests. - - path: ".*_test.go" - linters: - - gosec - text: "G306: Expect WriteFile permissions to be 0600 or less" + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - gosec + path: .*_test.go + text: 'G601: Implicit memory aliasing in for loop' + - linters: + - gosec + path: .*_test.go + text: 'G306: Expect WriteFile permissions to be 0600 or less' + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - goimports + settings: + goimports: + local-prefixes: + - github.com/NVIDIA/go-gpuallocator + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/gpuallocator/allocator.go b/gpuallocator/allocator.go index 076bb7f..e14405d 100644 --- a/gpuallocator/allocator.go +++ b/gpuallocator/allocator.go @@ -87,7 +87,7 @@ func (a *Allocator) Allocate(num int) []*Device { err := a.AllocateSpecific(devices...) if err != nil { - err = fmt.Errorf("Internal error while allocating GPUs: %v", err) + err = fmt.Errorf("internal error while allocating GPUs: %v", err) panic(err) } diff --git a/gpuallocator/besteffort_policy.go b/gpuallocator/besteffort_policy.go index 4c0f0bc..f13b774 100644 --- a/gpuallocator/besteffort_policy.go +++ b/gpuallocator/besteffort_policy.go @@ -277,7 +277,7 @@ func iterateGPUPartitions(devices []*Device, size int, callback func([][]*Device // the set '[[0 1 2 3 ], [4 5 6 7 ]]' as a candidate for // allocating 5 GPUs from a set of 8. p := gpuSetCountPadding(set) - if !(p == 0 || p == padding) { + if p != 0 && p != padding { return } @@ -311,7 +311,7 @@ func calculateGPUPairScore(gpu0 *Device, gpu1 *Device) int { } if len(gpu0.Links[gpu1.Index]) != len(gpu1.Links[gpu0.Index]) { - err := fmt.Errorf("Internal error in bestEffort GPU allocator: all P2PLinks between 2 GPUs should be bidirectional") + err := fmt.Errorf("internal error in bestEffort GPU allocator: all P2PLinks between 2 GPUs should be bidirectional") panic(err) }