internal

package
v0.30.41 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AnyType      = TypeOf[any]()
	AnySliceType = TypeOf[[]any]()
	ErrorType    = TypeOf[error]()
)

Functions

func CoerceSlice

func CoerceSlice(
	slice reflect.Value,
	elemTyp reflect.Type,
) (reflect.Value, bool)

CoerceSlice attempts to upcast the elements of a slice and return the newly promoted slice and true if successful. If elemType is nil, the most specific type will be inferred.

func CoerceToPtr

func CoerceToPtr(
	givenType reflect.Type,
	desiredType reflect.Type,
) reflect.Type

func CopyIndirect

func CopyIndirect(src any, target any)

CopyIndirect copies the contents of src into the target pointer or reflect.Value.

func CopySliceIndirect

func CopySliceIndirect(src []any, target any)

CopySliceIndirect copies the contents of src slice into the target pointer or reflect.Value.

func Exported

func Exported(t any) bool

func IsAny added in v0.30.29

func IsAny(typ reflect.Type) bool

IsAny returns true if tpe is assignable to any.

func IsNil

func IsNil(val any) bool

IsNil determine if the val is typed or untyped nil.

func IsStruct

func IsStruct(val any) bool

IsStruct returns true if val is a struct value.

func New

func New[T any]() *T

New creates a new T and optionally initializes it.

func NewWithTag

func NewWithTag(
	typ reflect.Type,
	tag reflect.StructTag,
) (any, error)

func TargetSliceValue

func TargetSliceValue(target any) reflect.Value

TargetSliceValue validates the interface contains a non-nil typed slice pointer and return reflect.Value.

func TargetValue

func TargetValue(target any) reflect.Value

TargetValue validates the interface contains a non-nil typed pointer and return reflect.Value.

func TypeOf

func TypeOf[T any]() reflect.Type

TypeOf returns reflect.Type of generic argument.

func ValueAs

func ValueAs[T any](v reflect.Value) (r T)

ValueAs returns the value of v As the type T. Provides panics if the value isn't assignable to T.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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