gen

package
v0.0.0-...-c0326d0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As[To any](in any) (To, bool)

As performs a type assertion to the given type. It returns the asserted value and a boolean indicating whether the assertion succeeded.

func Cast

func Cast[To any](in any) To

Cast performs a type assertion to the given type. It will panic if the type assertion fails.

func IsA

func IsA[V any](v any) bool

IsA checks if a value is of a certain type.

func New

func New[V any]() *V

New returns a pointer to a new zero value for a given type.

func Stub

func Stub[V any](args ...any) V

Stub is a stub left empty by intent.

For instance, to check generic types implement certain interfaces, a blank ('_') function declaration can be used to check the type definition.

Example:

func _[K]() MyInterface[K] {
	return Stub[MyImplementation[K]]()
}

func TODO

func TODO[V any](args ...any) V

TODO is a function to create holes when stubbing out more complex mechanisms.

By default, it will panic with 'TODO: provide a value of type <type>' where <type> is the type of V. The panic message can be altered by passing in additional args that will be printed as 'TODO: <args separated by space>'

func Zero

func Zero[V any]() V

Zero returns the zero value for a given type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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