reflectext

package
v0.0.338 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TryCast

func TryCast[T any](v any) (T, bool)

TryCast works similar to `v2, ok := v.(T)` Except it works through type alias'

func TryCastType

func TryCastType(v any, dest reflect.Type) (any, bool)

func Underlying

func Underlying(t reflect.Type) (ret reflect.Type)

Underlying returns the underlying type of t (without type alias)

https://github.com/golang/go/issues/39574#issuecomment-655664772

Types

type PrimitiveStringSerializer

type PrimitiveStringSerializer struct{}

PrimitiveStringSerializer is used to serialize primitive types (and a few more) from and to string This is not really intended to be user facing, and more as a simple building block for other mechanisms supports:

  • golang primitives (ints, uints, floats, bool, string)
  • type aliases
  • time.Time
  • primitive.ObjectID

func (PrimitiveStringSerializer) ValueFromString

func (pss PrimitiveStringSerializer) ValueFromString(str string, outType reflect.Type) (any, error)

func (PrimitiveStringSerializer) ValueToString

func (pss PrimitiveStringSerializer) ValueToString(v any) (string, error)

Jump to

Keyboard shortcuts

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