Skip to content

Commit

Permalink
datagen: Fix linter by using Read from "crypto/rand"
Browse files Browse the repository at this point in the history
Signed-off-by: Tatiana Nesterenko <[email protected]>
  • Loading branch information
tatiana-nspcc committed Feb 27, 2024
1 parent 1dafed3 commit b245563
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions internal/datagen/generator.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package datagen

import (
"crypto/rand"
"crypto/sha256"
"encoding/hex"
"math/rand"
"time"

"github.com/dop251/goja"
"go.k6.io/k6/js/modules"
Expand Down Expand Up @@ -35,10 +34,6 @@ type (
// TailSize specifies number of extra random bytes in the buffer tail.
const TailSize = 1024

func init() {
rand.Seed(time.Now().UnixNano())
}

func NewGenerator(vu modules.VU, size int) Generator {
if size <= 0 {
panic("size should be positive")
Expand All @@ -63,7 +58,7 @@ func (g *Generator) nextSlice() []byte {
if g.buf == nil {
// Allocate buffer with extra tail for sliding and populate it with random bytes
g.buf = make([]byte, g.size+TailSize)
rand.Read(g.buf) // Per docs, err is always nil here
_, _ = rand.Read(g.buf) // Per docs, err is always nil here
}

result := g.buf[g.offset : g.offset+g.size]
Expand Down

0 comments on commit b245563

Please sign in to comment.