reflect

package
v10.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotPointer is returned when a function receives a parameter that is not a pointer.
	ErrNotPointer = errors.New("out value is not pointer")
	// ErrNotCollection is returned when a function receives a parameter that is not a collection.
	ErrNotCollection = errors.New("out value is not collection")
	// ErrInvalidOutValue is returned when an out value cannot be set to the target value.
	ErrInvalidOutValue = errors.New("invalid out value type")
)

Functions

func AppendToSlice

func AppendToSlice(out interface{}, values ...interface{}) error

AppendToSlice appends values to a slice. `out` must be a pointer to a slice. `values` must be compatible with the slice type.

func NewCollectionValueInstance

func NewCollectionValueInstance(collection interface{}) (interface{}, error)

NewCollectionValueInstance receives a collection (slice, map) and returns a new instance of the collection's value type. If the collection value type is a pointer type, a pointer object to a new instance of the type value is returned.

func NewInstance

func NewInstance(value interface{}) interface{}

NewInstance returns a new instance of the same type as the input value. The returned value will contain the zero value of the type.

func SetMapValue

func SetMapValue(out interface{}, key interface{}, value interface{}) error

SetMapValue sets a value in a map. `out` must be a map. `key` must be compatible with the map key type. `value` must be compatible with the map value type.

func SetValue

func SetValue(out interface{}, value interface{}) (err error)

SetValue sets the `out` parameter to the specified value. `out` must be a pointer.

Types

This section is empty.

Jump to

Keyboard shortcuts

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