converter

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedTypeConversion = errors.New("unsupported type conversion")
)

Functions

func FromInterfaceTo added in v1.2.0

func FromInterfaceTo[T any](data interface{}) (T, error)

FromInterfaceTo converts data from type interface{} to any type given. The used switch case shows which type conversions are supported. If the type is not supported, ErrUnsupportedTypeConversion is thrown.

func ToPointer

func ToPointer[E any](toConvert E) *E

ToPointer converts any type (E) to pointer (*E)

func ToPointerOrNil

func ToPointerOrNil[T constraints.Ordered](toConvert T) *T

ToPointerOrNil converts like ToPointer but returns nil if toConvert is a zero value.

func ToValue

func ToValue[E any](toConvert *E) E

ToValue converts any pointer (*E) to value (E). Panics if toConvert is a nil pointer.

func ToValueOrZero

func ToValueOrZero[T constraints.Ordered](toConvert *T) T

ToValueOrZero converts like ToValue but returns a zero value if toConvert is nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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