factory-go: github.com/bluele/factory-go/factory Index | Files

package factory

import "github.com/bluele/factory-go/factory"

Index

Package Files

factory.go utils.go

Variables

var (
    TagName = "factory"
)

type Args Uses

type Args interface {
    Instance() interface{}
    Parent() Args
    Context() context.Context
    // contains filtered or unexported methods
}

type Factory Uses

type Factory struct {
    // contains filtered or unexported fields
}

func NewFactory Uses

func NewFactory(model interface{}) *Factory

NewFactory returns a new factory for specified model class Each generator is applied in the order in which they are declared

func (*Factory) Attr Uses

func (fa *Factory) Attr(name string, gen func(Args) (interface{}, error)) *Factory

func (*Factory) Construct Uses

func (fa *Factory) Construct(ptr interface{}) error

Bind values of a new objects to a pointer to struct.

ptr: a pointer to struct

func (*Factory) ConstructWithContextAndOption Uses

func (fa *Factory) ConstructWithContextAndOption(ctx context.Context, ptr interface{}, opt map[string]interface{}) error

Bind values of a new objects to a pointer to struct with context and option.

ctx: context object ptr: a pointer to struct opt: attibute values

func (*Factory) ConstructWithOption Uses

func (fa *Factory) ConstructWithOption(ptr interface{}, opt map[string]interface{}) error

Bind values of a new objects to a pointer to struct with option.

ptr: a pointer to struct opt: attibute values

func (*Factory) Create Uses

func (fa *Factory) Create() (interface{}, error)

func (*Factory) CreateWithContext Uses

func (fa *Factory) CreateWithContext(ctx context.Context) (interface{}, error)

func (*Factory) CreateWithContextAndOption Uses

func (fa *Factory) CreateWithContextAndOption(ctx context.Context, opt map[string]interface{}) (interface{}, error)

func (*Factory) CreateWithOption Uses

func (fa *Factory) CreateWithOption(opt map[string]interface{}) (interface{}, error)

func (*Factory) MustCreate Uses

func (fa *Factory) MustCreate() interface{}

func (*Factory) MustCreateWithOption Uses

func (fa *Factory) MustCreateWithOption(opt map[string]interface{}) interface{}

func (*Factory) OnCreate Uses

func (fa *Factory) OnCreate(cb func(Args) error) *Factory

OnCreate registers a callback on object creation. If callback function returns error, object creation is failed.

func (*Factory) SeqInt Uses

func (fa *Factory) SeqInt(name string, gen func(int) (interface{}, error)) *Factory

func (*Factory) SeqString Uses

func (fa *Factory) SeqString(name string, gen func(string) (interface{}, error)) *Factory

func (*Factory) SubFactory Uses

func (fa *Factory) SubFactory(name string, sub *Factory) *Factory

func (*Factory) SubRecursiveFactory Uses

func (fa *Factory) SubRecursiveFactory(name string, sub *Factory, getLimit func() int) *Factory

func (*Factory) SubRecursiveSliceFactory Uses

func (fa *Factory) SubRecursiveSliceFactory(name string, sub *Factory, getSize, getLimit func() int) *Factory

func (*Factory) SubSliceFactory Uses

func (fa *Factory) SubSliceFactory(name string, sub *Factory, getSize func() int) *Factory

type Stacks Uses

type Stacks []*int64

func (*Stacks) Has Uses

func (st *Stacks) Has(idx int) bool

func (*Stacks) Next Uses

func (st *Stacks) Next(idx int) bool

func (*Stacks) Pop Uses

func (st *Stacks) Pop(idx, delta int)

func (*Stacks) Push Uses

func (st *Stacks) Push(idx, delta int)

func (*Stacks) Set Uses

func (st *Stacks) Set(idx, val int)

Set method is not goroutine safe.

func (*Stacks) Size Uses

func (st *Stacks) Size(idx int) int64

Package factory imports 6 packages (graph) and is imported by 3 packages. Updated 2019-01-14. Refresh now. Tools for package owners.