Documentation
¶
Overview ¶
Package typeutil contains a collection of type-related utility functions.
This package provides a set of utility functions and definitions to work with generic types in Go. It also provides serialization and deserialization functions to safely transmit, store and retrieve data between different systems (e.g., databases, queues, caches, etc.).
Index ¶
- func Decode(msg string, data any) error
- func Deserialize(msg string, data any) error
- func Encode(data any) (string, error)
- func IsNil(v any) bool
- func IsZero[T any](v T) bool
- func Pointer[T any](v T) *T
- func Serialize(data any) (string, error)
- func Value[T any](p *T) T
- func Zero[T any](_ T) T
- type Float
- type Int
- type Number
- type Ordered
- type UInt
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
Decode decodes a message encoded with the Encode function to the provided data object. The value underlying data must be a pointer to the correct type for the next data item received.
func Deserialize ¶ added in v1.69.0
Deserialize decodes a message encoded with the Serialize function to the provided data object. The value underlying data must be a pointer to the correct type for the next data item received.
func IsZero ¶
IsZero returns true if the input value is equal to the zero instance (e.g. empty string, 0 int, nil pointer).
func Serialize ¶ added in v1.68.0
Serialize encodes the input data to JSON/base64 format into a string.