refl

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deref

func Deref(t reflect.Type) reflect.Type

Deref is Indirect for reflect.Types Pulled from sqlx/reflectx: https://tinyurl.com/y9akfp5n

func DerefDeep

func DerefDeep(t reflect.Type) reflect.Type

DerefDeep derefs all the way down.

func ElementTypeFromSlice

func ElementTypeFromSlice(sliceIn interface{}) (reflect.Type, error)

ElementTypeFromSlice takes a slice or a pointer to slice and returns the type of its element(s).

func GetFieldsByTag

func GetFieldsByTag(in interface{}, tag string) map[string]interface{}

GetFieldsByTag will get all fields in an object for a given tag.

func GetFieldsByTagWithTagValues

func GetFieldsByTagWithTagValues(
	in interface{},
	tag string,
	iterators ...fieldTagIterator,
) map[string]TagValueInterface

GetFieldsByTagWithTagValues will get all fields in an object for a given tag and also the values associated with the specified tag. TODO: This should probably return an iterator or something so that the

resulting code doesn't repeat the iteration.

func GetInterfaceName

func GetInterfaceName(in interface{}) string

GetInterfaceName will get the resolved name of an interface.

func GetInterfaceSlice

func GetInterfaceSlice(in interface{}) interface{}

GetInterfaceSlice for some arbitrary interface get an interface that represents a slice of its type.

func GetTagValues

func GetTagValues(
	in interface{}, tag string, formatters ...(func(string) string),
) []string

GetTagValues will get all the fields tag values as a slice.

func GuessTableName

func GuessTableName(in interface{}) (string, error)

func InitSetField

func InitSetField(fieldVal, newVal reflect.Value) error

func InterfaceToSQLValue

func InterfaceToSQLValue(
	in interface{},
) string

InterfaceToSQLValue will take an interface, and try to cleverly convert it to the best SQL value representation.

func IsZeroValue

func IsZeroValue(in interface{}) bool

func LowerSnakeToUpperCamel

func LowerSnakeToUpperCamel(lowerSnake string) string

func UpperCamelToSnake

func UpperCamelToSnake(raw string) string

Types

type BSTag

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

func (BSTag) AllProperties

func (self BSTag) AllProperties() []string

func (BSTag) HasProperty

func (self BSTag) HasProperty(key string) bool

func (BSTag) Name

func (self BSTag) Name() string

func (BSTag) Property

func (self BSTag) Property(i int) string

func (BSTag) Value

func (self BSTag) Value() string

type FieldWithBS

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

func (FieldWithBS) Interface

func (self FieldWithBS) Interface() interface{}

func (FieldWithBS) Name

func (self FieldWithBS) Name() string

func (FieldWithBS) Tag

func (self FieldWithBS) Tag(key string) *BSTag

func (FieldWithBS) Tags

func (self FieldWithBS) Tags() []*BSTag

type GroupFieldWithBSBy

type GroupFieldWithBSBy func(*GroupedFieldsWithBS, *FieldWithBS)

GroupFieldWithBSBy takes in a new FieldWithBS and the existing GroupedFieldsWithBS and inserts the FieldWithBs appropriately according to its grouping function.

func GroupFieldsByFieldName

func GroupFieldsByFieldName() GroupFieldWithBSBy

GroupFieldsByFieldName is a grouping function that will group all the input FieldWithBS by its field name.

func GroupFieldsByTagName

func GroupFieldsByTagName() GroupFieldWithBSBy

GroupFieldsByTagName is a grouping function that will group all the input FieldWithBS by its tag name.

func GroupFieldsByTagValue

func GroupFieldsByTagValue(
	tagNames ...string,
) GroupFieldWithBSBy

GroupFieldsByTagValue is a grouping function that will group all the input FieldWithBS by its tag value.

type GroupedFieldsWithBS

type GroupedFieldsWithBS map[string]*FieldWithBS

GroupedFieldsWithBS is a map of some grouping string to a FieldWithBS.

func GetGroupedFieldsWithBS

func GetGroupedFieldsWithBS(
	in interface{},
	byFilters ...GroupFieldWithBSBy,
) []*GroupedFieldsWithBS

GetGroupedFieldsWithBS takes an interface and returns a series of maps that group FieldWithBS by the provided grouping functions in provided order.

type TagValueInterface

type TagValueInterface struct {
	TagValue  string
	Interface interface{}
}

TagValueInterface is a type which holds both a TagValue and an interface.

func (*TagValueInterface) IsNil added in v0.2.3

func (tvi *TagValueInterface) IsNil() bool

IsZero checks if the value of the TagValueInterface is nil.

func (*TagValueInterface) IsUnset

func (tvi *TagValueInterface) IsUnset() bool

IsUnset checks if the value of the TagValueInterface is unset.

func (*TagValueInterface) IsZero added in v0.2.3

func (tvi *TagValueInterface) IsZero() bool

IsZero checks if the value of the TagValueInterface is zero.

Jump to

Keyboard shortcuts

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