Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ linters:
deny:
- pkg: "github.com/databricks/cli/experimental"
desc: "must not import experimental/ packages; use an interface or move the dependency"
no-legacy-rand:
deny:
- pkg: "math/rand$"
desc: "use math/rand/v2 instead of math/rand"
forbidigo:
forbid:
- pattern: 'term\.IsTerminal'
Expand Down
4 changes: 2 additions & 2 deletions integration/libs/locker/locker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"io"
"io/fs"
"math/rand"
"math/rand/v2"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -40,7 +40,7 @@ func TestLock(t *testing.T) {
var wg sync.WaitGroup
for currentIndex := range numConcurrentLocks {
wg.Go(func() {
time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
time.Sleep(time.Duration(rand.IntN(100)) * time.Millisecond)
lockerErrs[currentIndex] = lockers[currentIndex].Lock(ctx, false)
})
}
Expand Down
6 changes: 3 additions & 3 deletions libs/template/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"errors"
"fmt"
"math/rand"
"math/rand/v2"
"net/url"
"os"
"regexp"
Expand Down Expand Up @@ -66,9 +66,9 @@ func loadHelpers(ctx context.Context) template.FuncMap {
"regexp": func(expr string) (*regexp.Regexp, error) {
return regexp.Compile(expr)
},
// Alias for https://pkg.go.dev/math/rand#Intn. Returns, as an int, a non-negative pseudo-random number in the half-open interval [0,n).
// Alias for https://pkg.go.dev/math/rand/v2#IntN. Returns, as an int, a non-negative pseudo-random number in the half-open interval [0,n).
"random_int": func(n int) int {
return rand.Intn(n)
return rand.IntN(n)
},
// Alias for https://pkg.go.dev/github.com/google/uuid#New. Returns, as a string, a UUID which is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC 4122.
"uuid": func() string {
Expand Down
Loading