guarded

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CastType

func CastType[Target any](from any, to Target) (Target, error)

CastType attempts to cast the given value to the target type If the value is nil, it will return the target value If the value is already of the correct type, it will return it Numbers are a bit tricky, they are automatically converted to float64 when unmarshalled from JSON, so we need to check for that and convert to what we expect

See implementation for more details

func ExpectsPayload

func ExpectsPayload(param any) types.ExpectedPayloadType

ExpectsPayload returns whether the given parameter expects a payload or not by checking if it is a void type

func MakeCastError

func MakeCastError(expected, got any) error

Attempts to construct a CastError from the expected and gotten types

Types

This section is empty.

Jump to

Keyboard shortcuts

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