package
0.4.2
Repository: https://github.com/theopenlane/utils.git
Documentation: pkg.go.dev

# Functions

From returns the value associated with the wanted type from the context It performs a type assertion to convert the value to the desired type T If the type assertion is successful, it returns the value and true If the type assertion fails, it returns the zero value of type T and false.
FromOr returns the value associated with the wanted type or the given default value if the type is not found This function is useful when you want to ensure that a value is always returned from the context, even if the context does not contain a value of the desired type.
FromOrFunc returns the value associated with the wanted type or the result of the given function if the type is not found This function is useful when the default value is expensive to compute or when the default value depends on some runtime conditions.
MustFrom is similar to from, except that it panics if the type assertion fails / the value is not in the context.
With returns a copy of parent that contains the given value which can be retrieved by calling From with the resulting context The function uses a generic key type to ensure that the stored value is type-safe and can be uniquely identified and retrieved without risk of key collisions.