grafana/pkg/tsdb/testdatasource/utils.go

23 lines
399 B
Go
Raw Normal View History

package testdatasource
import (
"math/rand"
"time"
)
type randomStringProvider struct {
r *rand.Rand
data []string
}
func newRandomStringProvider(data []string) *randomStringProvider {
return &randomStringProvider{
r: rand.New(rand.NewSource(time.Now().UnixNano())),
data: data,
}
}
func (p *randomStringProvider) Next() string {
return p.data[p.r.Int31n(int32(len(p.data)))]
}