Documentation ¶
Index ¶
- Variables
- type BoolSpec
- type CacheKey
- type Float32Spec
- type Float64Spec
- type Generator
- func (g *Generator) Bool(key string, spec BoolSpec) bool
- func (g *Generator) Cache() map[string]interface{}
- func (g *Generator) Float32(key string, spec Float32Spec) float32
- func (g *Generator) Float64(key string, spec Float64Spec) float64
- func (g *Generator) Generate(key string, spec interface{}, f func(r *rand.Rand) interface{}) interface{}
- func (g *Generator) Int(key string, spec IntSpec) int
- func (g *Generator) Int64(key string, spec Int64Spec) int64
- func (g *Generator) Rand(key string) *rand.Rand
- func (g *Generator) String(key string, spec StringSpec) string
- func (g *Generator) Time(key string, spec TimeSpec) time.Time
- func (g *Generator) URL(key string, spec URLSpec) url.URL
- func (g *Generator) Uint(key string, spec UintSpec) uint
- type Int64Spec
- type IntSpec
- type Some
- type StringSpec
- type TimeSpec
- type URLSpec
- type UintSpec
Constants ¶
This section is empty.
Variables ¶
var ( // Float64 is a default float spec. Float64 Float64Spec = Float64Spec{ 1, 0, } // Float32 is a default float spec. Float32 Float32Spec = Float32Spec{ 1, 0, } )
Functions ¶
This section is empty.
Types ¶
type Float32Spec ¶
Float32Spec is a spec of a float64.
func (*Float32Spec) Generate ¶
func (s *Float32Spec) Generate(r *rand.Rand) float32
Generate generates a random bool from r.
func (Float32Spec) WithMax ¶
func (s Float32Spec) WithMax(max float32) Float32Spec
WithMax returns new spec with given max.
func (Float32Spec) WithMin ¶
func (s Float32Spec) WithMin(min float32) Float32Spec
WithMin returns new spec with given min.
type Float64Spec ¶
Float64Spec is a spec of a float64.
func (Float64Spec) Generate ¶
func (s Float64Spec) Generate(r *rand.Rand) float64
Generate generates a random bool from r.
func (Float64Spec) WithMax ¶
func (s Float64Spec) WithMax(max float64) Float64Spec
WithMax returns new spec with given max.
func (Float64Spec) WithMin ¶
func (s Float64Spec) WithMin(min float64) Float64Spec
WithMin returns new spec with given min.
type Generator ¶
type Generator struct { // LocalRand is a instance specific random number generator. LocalRand *rand.Rand // LocalCache is a instance specific cache store. LocalCache map[string]interface{} }
Generator generates and caches a dummy data.
func (*Generator) Float32 ¶
func (g *Generator) Float32(key string, spec Float32Spec) float32
Float32 generates a float according to a key and spec.
func (*Generator) Float64 ¶
func (g *Generator) Float64(key string, spec Float64Spec) float64
Float64 generates a float according to a key and spec.
func (*Generator) Rand ¶
Rand returns a random number generator for the specific key. GlobalRand or LocalCache are returned for the empty key.
func (*Generator) String ¶
func (g *Generator) String(key string, spec StringSpec) string
String generates a string according to a key and spec.
type Int64Spec ¶
Int64Spec is spec of a int64.
type IntSpec ¶
IntSpec is spec of a int.
type Some ¶
type Some struct{}
func (Some) Float32 ¶
func (s Some) Float32() Float32Spec
func (Some) Float64 ¶
func (s Some) Float64() Float64Spec
func (Some) String ¶
func (s Some) String() StringSpec
type StringSpec ¶
type StringSpec struct {
Len int
}
BoolSpec is a spec of a string.
var String StringSpec = StringSpec{
10,
}
String is a default string spec.
func (StringSpec) Generate ¶
func (s StringSpec) Generate(r *rand.Rand) string
Generate generates a random string from r.
func (StringSpec) WithLen ¶
func (s StringSpec) WithLen(len int) StringSpec
WithLen returns new spec with given len.
type TimeSpec ¶
TimeSpec is a spec of a time.Time.
var Time TimeSpec = TimeSpec{ time.Unix(0, 0), time.Date(3000, time.January, 1, 0, 0, 0, 0, time.UTC), }
Bool is a default time.Time spec.
type URLSpec ¶
type URLSpec struct {
Schemes []string
}
URLSpec is a spec of a url.URL.
func (URLSpec) WithSchemes ¶
WithSchemes returns new spec with given schemes.