Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Default ¶
func Default[T comparable](values ...T) T
Default returns the first non-zero value. If all values are zero, return the zero value.
Default("", "foo") // "foo" Default("bar", "foo") // "bar" Default("", "", "foo") // "foo"
func Pointer ¶
func Pointer[T any](value T) *T
Pointer returns a pointer to the value.
Pointer("foo") // *string("foo") Pointer(1) // *int(1)
func Tap ¶
func Tap[T any](value T, callbacks ...func(T)) T
Tap calls the given callback with the given value then returns the value.
Tap("foo", func(s string) { fmt.Println(s) // "foo" and os.Stdout will print "foo" }, func(s string) { // more callbacks }...)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.