convert

package
v0.62.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0 Imports: 0 Imported by: 1 module, 0 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 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
}...)

func Transform

func Transform[T, R any](value T, callback func(T) R) R

Transform calls the given callback with the given value then return the result.

Transform(1, strconv.Itoa) // "1"
Transform("foo", func(s string) *foo {
	return &foo{Name: s}
}) // &foo{Name: "foo"}

func With

func With[T any](value T, callbacks ...func(T) T) T

With calls the given callbacks with the given value then return the value.

With("foo", func(s string) string {
	return s + "bar"
}, func(s string) string {
	return s + "baz"
}) // "foobarbaz"

Types

This section is empty.

Jump to

Keyboard shortcuts

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