package
Version:
v1.100.0
Opens a new window with list of versions in this module.
Published: Sep 11, 2024
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package typeutil contains a collection of type-related generic utility
functions.
This package provides a set of utility functions and definitions for working
with generic types in Go.
BoolToInt converts a boolean value to an integer.
NOTE: this is currently the fastest implementation as it will be optimized by
the compiler with a MOVBLZX instruction.
Ref.:
IsNil returns true if the input value is nil.
IsZero returns true if the input value is equal to the zero instance (e.g. empty string, 0 int, nil pointer).
func Pointer[T any](v T) *T
Pointer returns the address of v.
func Value[T any](p *T) T
Value returns the value of the provided pointer or the type default (zero value) if nil.
Zero returns the zero instance (e.g. empty string, 0 int, nil pointer).
Float is a constraint for float types.
Int is a constraint for signed integer types.
Number is a constraint for all integer and float numbers.
Ordered is a constraint that permits any ordered type:
any type that supports the operators < <= >= >.
UInt is a constraint for unsigned integer types.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.