attr

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2021 License: LGPL-3.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetField

func SetField(data interface{}, field reflect.Value, fieldType reflect.StructField, attr Attributer) (interface{}, error)

Types

type Attributer

type Attributer interface {
	Name() string
	ColName() string
	Kind() Type
	Gen(data interface{}) (interface{}, error)
	Process(process Processor) Attributer
	GetVal() interface{}
	SetVal(val interface{}) error
	GetObject() interface{}
}

Attributer define attribute interface for factory

func Attr

func Attr(name string, genFunc func() interface{}, options ...string) Attributer

Attr create interface{} attributer with generated function

the return value of generated function must has the specific type

func Bool

func Bool(name string, genFunc func() bool, options ...string) Attributer

func Bytes

func Bytes(name string, genFunc func() []byte, options ...string) Attributer

Bytes create []byte attributer with generated function

func Float

func Float(name string, genFunc func() float64, options ...string) Attributer

Float create float attributer with generated function

func Int

func Int(name string, genFunc func() int, options ...string) Attributer

Int create int attributer with generated function

func Str

func Str(name string, genFunc func() string, options ...string) Attributer

Str create string attributer with generated function

func Time

func Time(name string, genFunc func() time.Time, options ...string) Attributer

func Uint

func Uint(name string, genFunc func() uint, options ...string) Attributer

Uint create uint attributer with generated function

type Processor

type Processor func(attr Attributer) error

Processor define process method interface

type Type

type Type int8

Type represent attributes type

const (
	// IntAttr int-family attribute
	IntAttr Type = iota + 1
	// UintAttr uint-family attribute
	UintAttr
	// FloatAttr float-family attribute
	FloatAttr
	// StringAttr string attribute
	StringAttr
	// BytesAttr []byte attribute
	BytesAttr
	// TimeAttr time.Time attribute
	TimeAttr
	// BoolAttr boolean attribute
	BoolAttr
	// UnknownAttr interface{} attribute
	UnknownAttr
)

Jump to

Keyboard shortcuts

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