Documentation
¶
Overview ¶
Package types provides utility functions for checking the type and value of variables. It includes methods for determining if a value is a "zero" value for its type, such as empty strings, nil pointers, zero numeric values, and more. This package is essential for validation and conditional logic based on variable states across the application. It leverages the reflect package to inspect types at runtime.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAlpha ¶
IsAlpha checks if the input string consists only of alphabetic characters.
Parameters ¶
- s: The string to be checked.
Returns ¶
- A boolean value indicating whether the string is alphabetic (true) or not (false).
func IsZeroValue ¶
func IsZeroValue(i interface{}) bool
IsZeroValue checks if the provided interface{} 'i' holds a value that is considered "zero" or "empty" for its type. For pointers, it also checks if the pointed-to value is a zero value, except for pointers to integers or booleans.
This includes:
- nil pointers
- empty strings
- false for booleans
- zero for numeric types (integers, unsigned integers, floats)
- nil for slices, maps, interfaces, and channels
- time.Time structs representing the zero time
- structs where all fields are "zero" values
Parameters ¶
- i: The interface{} to check for a "zero" or "empty" value.
Returns ¶
- A bool indicating if 'i' is a "zero" or "empty" value.
Types ¶
This section is empty.