diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index dc10bd37..8a36c2c5 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -5,8 +5,18 @@ on: workflow_dispatch: jobs: + lint: + name: "Lint" + if: "${{ !endsWith(github.actor, '[bot]') }}" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: projectdiscovery/actions/setup/go@v1 + - uses: projectdiscovery/actions/golangci-lint@v1 + build: name: Test Builds + needs: ["lint"] runs-on: ${{ matrix.os }} strategy: matrix: diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml deleted file mode 100644 index c562c501..00000000 --- a/.github/workflows/lint-test.yml +++ /dev/null @@ -1,24 +0,0 @@ - - -name: 🙏🏻 Lint Test -on: - pull_request: - workflow_dispatch: - -jobs: - lint: - name: Lint Test - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: 1.24.x - - name: Run golangci-lint - uses: golangci/golangci-lint-action@v3.7.0 - with: - version: latest - args: --timeout 5m - working-directory: . diff --git a/ml/model_selection/model_selection.go b/ml/model_selection/model_selection.go index b7f78451..bde484b5 100644 --- a/ml/model_selection/model_selection.go +++ b/ml/model_selection/model_selection.go @@ -1,7 +1,7 @@ package modelselection import ( - "math/rand" + "math/rand/v2" ) func TrainTestSplit(dataset []interface{}, testSize float64) (train, test []interface{}) { diff --git a/rand/number.go b/rand/number.go index 22b6e7e8..53f59b04 100644 --- a/rand/number.go +++ b/rand/number.go @@ -4,7 +4,7 @@ import ( "crypto/rand" "errors" "math/big" - crand "math/rand" + crand "math/rand/v2" ) // IntN returns a uniform random value in [0, max). It errors if max <= 0. @@ -14,7 +14,7 @@ func IntN(max int) (int, error) { } nBig, err := rand.Int(rand.Reader, big.NewInt(int64(max))) if err != nil { - return crand.Intn(max), nil + return crand.IntN(max), nil } return int(nBig.Int64()), nil } diff --git a/regexp/regexp.go b/regexp/regexp.go index 4f6811b9..d50e4949 100644 --- a/regexp/regexp.go +++ b/regexp/regexp.go @@ -98,7 +98,7 @@ func compileWithRE2(pattern string) (*Regexp, error) { os.Stderr = devNull defer func() { os.Stderr = originalStderr - devNull.Close() + _ = devNull.Close() }() } diff --git a/slice/sliceutil.go b/slice/sliceutil.go index 49a4000d..c70bca7c 100644 --- a/slice/sliceutil.go +++ b/slice/sliceutil.go @@ -1,7 +1,7 @@ package sliceutil import ( - "math/rand" + "math/rand/v2" "strconv" "time" @@ -61,7 +61,7 @@ func DedupeFunc[T any](inputSlice []T, keyFunc func(T) any) (result []T) { // PickRandom item from a slice of elements func PickRandom[T any](v []T) T { - return v[rand.Intn(len(v))] + return v[rand.IntN(len(v))] } // Contains if a slice contains an element