Documentation
¶
Index ¶
- func ToBool(v any) (bool, error)
- func ToBoolDefault(v any, def bool) bool
- func ToDuration(v any) (time.Duration, error)
- func ToDurationDefault(v any, def time.Duration) time.Duration
- func ToFloat64(v any) (float64, error)
- func ToFloat64Default(v any, def float64) float64
- func ToInt(v any) (int, error)
- func ToIntDefault(v any, def int) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToBool ¶
ToBool converts a value of any type to a boolean. It supports boolean types, string representations of booleans, and numeric types (0 is false, non-zero is true). Returns an error if the conversion is not possible.
func ToBoolDefault ¶
ToBoolDefault is ToBool but returns def instead of an error on failure.
func ToDuration ¶
ToDuration converts a value of any type to a time.Duration. It supports time.Duration, string representations (using time.ParseDuration), and numeric types (interpreted as seconds). Returns an error if the conversion is not possible.
func ToDurationDefault ¶
ToDurationDefault is ToDuration but returns def instead of an error on failure.
func ToFloat64 ¶
ToFloat64 converts a value of any type to a float64. It supports various numeric types, string representations of floats, and fmt.Stringer implementations. Returns an error if the conversion is not possible.
func ToFloat64Default ¶
ToFloat64Default is ToFloat64 but returns def instead of an error on failure.
func ToInt ¶
ToInt converts a value of any type to an int. It supports various numeric types, string representations of integers, and fmt.Stringer implementations. Returns an error if the conversion is not possible or if the value overflows.
func ToIntDefault ¶
ToIntDefault is ToInt but returns def instead of an error on failure.
Types ¶
This section is empty.