Documentation ¶
Index ¶
- Constants
- func ConsumeGenerator[T any](g Generator[T]) []T
- func ConsumeUntil[T any](g Generator[T], n int) []T
- func Fake[T any](val T, rules ...Rule[T]) (T, error)
- func InfiniteStream[T any](ctx context.Context, seed T, in chan T, rules ...Rule[T]) error
- type Generator
- func ChainRandom[T any](limit int, g ...Generator[T]) Generator[T]
- func ChainRoundRobin[T any](limit int, g ...Generator[T]) Generator[T]
- func GeneratorFromIO[T any](file io.ReadSeeker, parser LineParser[T]) Generator[T]
- func Infinite[T any](g Generator[T]) Generator[T]
- func RulesToGenerator[T any](t T, rs ...Rule[T]) Generator[T]
- type InfiniteGenerator
- type LineGenerator
- type LineParser
- type LineReaderSeeker
- func (lrs *LineReaderSeeker) Lines() (int, error)
- func (lrs *LineReaderSeeker) RandomLine() (string, error)
- func (lrs *LineReaderSeeker) Read(p []byte) (n int, err error)
- func (lrs *LineReaderSeeker) Seek(offset int64, whence int) (int64, error)
- func (lrs *LineReaderSeeker) SeekLine(lineNumber int, whence int) error
- type OneFieldRule
- type RandomChainGenerator
- type RoundRobinChainGenerator
- type Rule
- func ArrayGenerator[T any](fieldName string, n int, gs ...Generator[T]) Rule[T]
- func RandomFloat[T any](fieldName string, start, end float64) Rule[T]
- func RandomInt[T any](fieldName string, start, end int) Rule[T]
- func RandomPick[T any, F any](fieldName string, vals ...F) Rule[T]
- func RoundRobinGenerator[T any](fieldName string, n int, gs ...Generator[T]) Rule[T]
- type Runner
- type Step
- type StepGenerator
Constants ¶
View Source
const (
StructTagName = "fakenews"
)
Variables ¶
This section is empty.
Functions ¶
func ConsumeGenerator ¶
func ConsumeUntil ¶
Types ¶
type Generator ¶
func GeneratorFromIO ¶
func GeneratorFromIO[T any](file io.ReadSeeker, parser LineParser[T]) Generator[T]
func RulesToGenerator ¶
type InfiniteGenerator ¶
type InfiniteGenerator[T any] struct { // contains filtered or unexported fields }
func (InfiniteGenerator[T]) Iter ¶
func (i InfiniteGenerator[T]) Iter() Generator[T]
func (InfiniteGenerator[T]) Next ¶
func (i InfiniteGenerator[T]) Next() (T, bool)
type LineGenerator ¶
type LineGenerator[T any] struct { // contains filtered or unexported fields }
func (LineGenerator[T]) Iter ¶
func (l LineGenerator[T]) Iter() Generator[T]
func (LineGenerator[T]) Next ¶
func (l LineGenerator[T]) Next() (T, bool)
type LineParser ¶
type LineReaderSeeker ¶
type LineReaderSeeker struct {
// contains filtered or unexported fields
}
func NewLineReaderSeeker ¶
func NewLineReaderSeeker(rs io.ReadSeeker) *LineReaderSeeker
func (*LineReaderSeeker) Lines ¶
func (lrs *LineReaderSeeker) Lines() (int, error)
Updated Lines function
func (*LineReaderSeeker) RandomLine ¶
func (lrs *LineReaderSeeker) RandomLine() (string, error)
type OneFieldRule ¶
type OneFieldRule[T any] struct { // contains filtered or unexported fields }
func (OneFieldRule[T]) FieldName ¶
func (o OneFieldRule[T]) FieldName() string
func (OneFieldRule[T]) Run ¶
func (o OneFieldRule[T]) Run(current *T) (T, error)
type RandomChainGenerator ¶
type RandomChainGenerator[T any] struct { // contains filtered or unexported fields }
func (RandomChainGenerator[T]) Iter ¶
func (c RandomChainGenerator[T]) Iter() Generator[T]
func (RandomChainGenerator[T]) Next ¶
func (c RandomChainGenerator[T]) Next() (T, bool)
type RoundRobinChainGenerator ¶
type RoundRobinChainGenerator[T any] struct { // contains filtered or unexported fields }
func (RoundRobinChainGenerator[T]) Iter ¶
func (c RoundRobinChainGenerator[T]) Iter() Generator[T]
func (RoundRobinChainGenerator[T]) Next ¶
func (c RoundRobinChainGenerator[T]) Next() (T, bool)
type Rule ¶
func ArrayGenerator ¶
ArrayGenerator is a generator that will set a random array of values from the given list of generators to the field.
func RandomFloat ¶
RandomFloat is a generator that will set a random float between the given start and end values to the field.
func RandomInt ¶
RandomInt is a generator that will set a random integer between the given start and end values to the field.
func RandomPick ¶
RandomPick is a generator that will pick a random value from the given list of values and set it to the field.
type StepGenerator ¶
type StepGenerator[T any] struct { // contains filtered or unexported fields }
func (StepGenerator[T]) Add ¶
func (sg StepGenerator[T]) Add(s Step[T]) StepGenerator[T]
func (StepGenerator[T]) Iter ¶
func (s StepGenerator[T]) Iter() Generator[T]
func (StepGenerator[T]) Next ¶
func (s StepGenerator[T]) Next() (T, bool)
Click to show internal directories.
Click to hide internal directories.