MCPcopy
hub / github.com/grafana/k6 / NewRandSource

Function NewRandSource

js/common/randsource.go:16–22  ·  view source on GitHub ↗

NewRandSource is copied from Sobek's source code: https://github.com/grafana/sobek/blob/master/sobek/main.go#L44 The returned RandSource is NOT safe for concurrent use: https://golang.org/pkg/math/rand/#NewSource

()

Source from the content-addressed store, hash-verified

14// The returned RandSource is NOT safe for concurrent use:
15// https://golang.org/pkg/math/rand/#NewSource
16func NewRandSource() sobek.RandSource {
17 var seed int64
18 if err := binary.Read(crand.Reader, binary.LittleEndian, &seed); err != nil {
19 panic(fmt.Errorf("could not read random bytes: %w", err))
20 }
21 return rand.New(rand.NewSource(seed)).Float64 //nolint:gosec
22}

Callers 2

instantiateMethod · 0.92
setupJSRuntimeMethod · 0.92

Calls 2

ErrorfMethod · 0.80
ReadMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…