filler

package module
v0.0.0-...-aa6d8af Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 9 Imported by: 0

README

go-filler

Automatic data filler for GOlang

THIS IS NOW EXPERIMENTAL

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory func() (interface{}, FactoryState)

Factory はオブジェクトを生成する関数の定義

type FactoryState

type FactoryState int

FactoryState は、オブジェクトを生成する関数の戻り値

const (
	// None は、オブジェクトが生成されなかったことを示す
	None FactoryState = iota
	// Init は、オブジェクトが生成されて初期化されたことを示す
	Init
	// Done は、オブジェクトが生成されて全ての値がFillされたことを示す
	Done
)

type Filler

type Filler struct {
	FieldFilter func(structType reflect.Type, field reflect.StructField, value reflect.Value) bool
	// contains filtered or unexported fields
}

Filler はオブジェクトの内容を生成する

func RandomFiller

func RandomFiller(seed *RandomSeed) *Filler

RandomFiller は、プリミティブ型の値をランダムに設定する Filler を取得します

func (*Filler) Fill

func (g *Filler) Fill(object interface{})

Fill は、指定されたオブジェクトに再帰的に値を設定します

func (*Filler) Make

func (g *Filler) Make(typ reflect.Type) interface{}

Make は、指定された型に再帰的に値を設定したオブジェクトを取得します

func (*Filler) RegisterFunc

func (g *Filler) RegisterFunc(con TypedFactory)

RegisterFunc はオブジェクトの生成関数を登録します

func (*Filler) RegisterKind

func (g *Filler) RegisterKind(kind reflect.Kind, con Factory)

RegisterKind は kind: 型種別に紐づく con: 生成関数を登録します

func (*Filler) RegisterName

func (g *Filler) RegisterName(pkgPath string, typeName string, con Factory)

RegisterName は pkgPath: パッケージパス、typeName: 型名 に紐づく con: 生成関数を登録します

type RandomSeed

type RandomSeed struct {
	Random         *rand.Rand
	NilRate        float64
	SliceCapacity  int
	SliceMinimum   int
	StringCapacity int
	StringMinimum  int
	MapLength      int
}

RandomSeed は、RandomGeneratorで使用する乱数のパラメータです

func DefaultSeed

func DefaultSeed() RandomSeed

DefaultSeed は典型的な RandomSeed を取得します

type TypedFactory

type TypedFactory func(typ reflect.Type) (interface{}, FactoryState)

TypedFactory は型の指定に基づきオブジェクトを生成する関数の定義

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL