generic

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 4 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cast

func Cast[E any](v any) (E, error)

func Const

func Const[E, F any](e E) func(F) E

Const produces a function that takes an argument and returns the original argument, ignoring the passed-in value.

func Deref

func Deref[E any](e *E, defaultValue E) E

Deref returns the value e points to if it's non-nil. Otherwise, it returns the defaultValue.

func DerefFunc

func DerefFunc[E any](e *E, defaultFunc func() E) E

DerefFunc returns the value e points to if it's non-nil. Otherwise, it returns the result of calling defaultFunc.

func DerefZero

func DerefZero[E any](e *E) E

DerefZero returns the value e points to if it's non-nil. Otherwise, it returns the zero value for type E.

func Identity

func Identity[E any](e E) E

Identity is a function that returns its given parameters.

func PipeMap

func PipeMap[E any](e E, fs ...func(E) E) E

func Pointer

func Pointer[E any](e E) *E

Pointer returns a pointer for the given value.

func ReflectType

func ReflectType[E any]() reflect.Type

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[E any]() E

Zero returns the zero value for the given type.

func ZeroPointer

func ZeroPointer[E any]() *E

ZeroPointer returns a pointer to a zero value of type E.

Types

This section is empty.

Jump to

Keyboard shortcuts

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