Skip to content

Commit

Permalink
fix: use math/rand/v2 package from Go 1.22
Browse files Browse the repository at this point in the history
This new package pre-seeds the global rand source on every process start
so we don't need to maintain our own rand.Source variable.
  • Loading branch information
pbitty committed Oct 17, 2024
1 parent ab18f5e commit 65aad38
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"fmt"
"io"
"io/fs"
"math/rand"
rand "math/rand/v2"
"net/http"
"net/http/httptest"
"os"
Expand All @@ -30,8 +30,6 @@ import (
"github.com/go-task/task/v3/taskfile/ast"
)

var random = rand.New(rand.NewSource(time.Now().UnixNano()))

func init() {
_ = os.Setenv("NO_COLOR", "1")
}
Expand Down Expand Up @@ -1127,7 +1125,7 @@ func TestIncludesRemote(t *testing.T) {

for k, task := range tasks {
t.Run(task, func(t *testing.T) {
expectedContent := fmt.Sprint(random.Int63())
expectedContent := fmt.Sprint(rand.Int64())
t.Setenv("CONTENT", expectedContent)

outputFile := fmt.Sprintf("%d.%d.txt", i, k)
Expand Down

0 comments on commit 65aad38

Please sign in to comment.