grafana/pkg/tsdb/testdatasource/utils.go
Marcus Efraimsson 00e7c7c4b7
Testdata: Rename package to circumvent convention in go (#19409)
Before this change the tests for test datasource was not run.
2019-09-27 16:18:24 +02:00

23 lines
399 B
Go

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)))]
}