typeutil

package
v1.68.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package typeutil contains a collection of type-related utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode[T any](msg string, data T) error

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 Encode

func Encode[T any](data T) (string, error)

Encode encodes and serialize the input data to a gob/base64 string.

func IsNil

func IsNil[T any](v T) bool

IsNil returns true if the input value is nil.

func IsZero

func IsZero[T any](v T) bool

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

func Serialize[T any](data T) (string, error)

Serialize encodes the input data to a string that can be used for object comparison (json/base64).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL