func IsZero
IsZero returns true if the value represents a "zero" or "empty" state for its type. For example:
- Numbers: 0
- Strings: ""
- Slices/Maps: empty
- nil: true
- bool: false
- time.Time: IsZero()
- address: empty string
Package typeutil provides utility functions for converting between different types and checking their states. It aims...
Package typeutil provides utility functions for converting between different types and checking their states. It aims to provide consistent behavior across different types while remaining lightweight and dependency-free.
IsZero returns true if the value represents a "zero" or "empty" state for its type. For example:
ToBool converts any value to a boolean based on common programming conventions. For example:
ToInterfaceSlice converts various slice types to []any
ToMapIntInterface converts a map with int keys and any value type to map[int]any
ToMapStringInterface converts a map with string keys and any value type to map[string]any
ToString converts any value to its string representation. It supports a wide range of Go types including:
Example usage:
ToStringSlice converts various slice types to []string