reflect

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

README

Reflect GoDoc Go Report Card

reflect package contains a number of service functions intended for assigning values to variables and for traversing hierarchically all variables.

Installation

go get github.com/gotidy/reflect

Documentation

GoDoc

License

Apache 2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assign

func Assign(dst, src interface{}) error

Assign tries to convert source to destination. If possible, it converts the string to the destination type.

func AssignString

func AssignString(dst interface{}, src string) error

AssignString tries to convert the string to the appropriate type and assign it to the destination variable.

func AssignStringToValue

func AssignStringToValue(dst reflect.Value, src string) (err error)

AssignStringToValue tries to convert the string to the appropriate type and assign it to the destination variable.

func AssignValue

func AssignValue(dst, src reflect.Value) (err error)

AssignValue tries to convert source to destination. If possible, it converts the string to the destination type.

func Clear

func Clear(v interface{})

Clear variable

func Traverse

func Traverse(v interface{}, process ProcessValue) error

Traverse iterates through all the nested elements of the passed variable.

func TraverseFields

func TraverseFields(v interface{}, processField ProcessValue) error

TraverseFields iterates through all structs's fields of the passed variable.

func TraverseValue

func TraverseValue(v reflect.Value, process ProcessValue) error

TraverseValue iterates through all the nested elements of the passed variable.

func TraverseValueFields

func TraverseValueFields(v reflect.Value, processField ProcessValue) error

TraverseValueFields iterates through all structs's fields of the passed variable.

Types

type ProcessValue

type ProcessValue func(value reflect.Value, state *State, field *reflect.StructField) error

ProcessValue is type of callback function for Traverse function.

type State

type State struct {
	Path  string
	Depth int
	// Custom value.
	Value interface{}
}

State stores the traverse state.

Jump to

Keyboard shortcuts

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