structtag

package
v1.4.7 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotAPointer error when not a pointer.
	ErrNotAPointer = errors.New("Not a pointer")

	// ErrNotAStruct error when not a struct.
	ErrNotAStruct = errors.New("Not a struct")

	// ErrTypeNotSupported error when type not supported.
	ErrTypeNotSupported = errors.New("Type not supported")

	// ErrUndefinedTag error when Tag var is not defined.
	ErrUndefinedTag = errors.New("Undefined tag")

	// Tag set the main tag.
	Tag string

	// TagDefault set tag default.
	TagDefault string

	// TagHelper set tag usage.
	TagHelper string

	// TagDisabled used to not process an input.
	TagDisabled string

	// TagSeparator separe names on environment variables.
	TagSeparator string

	// Prefix is a string that would be placed at the beginning of the generated tags.
	Prefix string

	// ParseMap points to each of the supported types.
	ParseMap map[reflect.Kind]ReflectFunc

	// ParsePakagesTypeMap points to each of the suported pakage or user defined types
	// and it's priority over ParseMap.
	ParsePakagesTypeMap map[string]ReflectFunc

	// ParseNameMap point to name of each fueld and functions are defined by the user
	// it's priority over ParsePakagesTypeMap and ParseMap.
	ParseNameMap map[string]ReflectFunc
)

Functions

func Parse

func Parse(s interface{}, superTag string) (err error)

func ReflectArray added in v1.4.2

func ReflectArray(field *reflect.StructField, value *reflect.Value, tag string) (err error)

ReflectArray is called when the Parse encounters a sub-array in the current structure and then calls Parser again to treat the fields of the sub-array.

func ReflectStruct

func ReflectStruct(field *reflect.StructField, value *reflect.Value, tag string) (err error)

ReflectStruct is called when the Parse encounters a sub-structure in the current structure and then calls Parser again to treat the fields of the sub-structure.

func Reset

func Reset()

Reset maps caling setup function.

func SetBoolDefaults added in v1.4.2

func SetBoolDefaults(s interface{}, superTag string) (err error)

SetBoolDefaults populates the boolean fields of 's' with cfgDefault values.

func Setup

func Setup()

Setup maps and variables.

Types

type ReflectFunc

type ReflectFunc func(
	field *reflect.StructField,
	value *reflect.Value,
	tag string) (err error)

ReflectFunc type used to create funcrions to parse struct and tags.

Jump to

Keyboard shortcuts

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