Documentation
¶
Index ¶
- func And[T comparable](first T, second T) T
- func Clamp[T Number](value, min, max T) T
- func Default[T any](value *T, defaultValue T) T
- func Empty[T any]() T
- func FileExists(path string) (bool, error)
- func Or[T comparable](first T, second T) T
- func Ptr[T any](v T) *T
- func Ternary[T any](condition bool, ifTrue T, ifFalse T) T
- func Try(err error)
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func And ¶
func And[T comparable](first T, second T) T
Short circuit "And". Same as `first && second`. Uses the empty value of first for comparison.
func Default ¶
func Default[T any](value *T, defaultValue T) T
Gets deref of `value` or `defaultValue` if nil
func FileExists ¶
Returns true if exists, false if it doesn't, and false and error if unknowable.
func Or ¶
func Or[T comparable](first T, second T) T
Short circuit "Or". Same as `first || second`. Uses the empty value of first for comparison.
func Ptr ¶
func Ptr[T any](v T) *T
Same as `&v`. Direct pointer return, useful for untyped types, because you cannot take reference to then.
Types ¶
type Number ¶
type Number interface {
constraints.Integer | constraints.Float
}
Click to show internal directories.
Click to hide internal directories.