any

package
v0.31.10 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package any has general purpose utility functions for working with interfaces and generic types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldValues

func FieldValues(s interface{}) map[string]interface{}

FieldValues returns a map of names and values of the top-level exported fields in a struct. Anonymous fields are ignored, as well as non-exported fields.

func If

func If[T any](cond bool, i1, i2 T) T

If returns the first item if cond is true, or the second item if it is false.

func InterfaceSlice

func InterfaceSlice(in any) (o []any)

InterfaceSlice converts a slice of any object to a slice of interfaces of those internal objects if in is not an addressable item, it will panic

func IsNil

func IsNil(i any) bool

IsNil is a safe test for nil for any kind of variable, and will not panic If i points to a nil object, IsNil will return true, as opposed to i==nil which will return false

func IsSlice

func IsSlice(in any) bool

func SetFieldValues

func SetFieldValues(s interface{}, values map[string]interface{}) error

SetFieldValues will restore values the were extracted using FieldValues

func Zero

func Zero[T any]() T

Zero returns the zero value of a type.

Types

This section is empty.

Jump to

Keyboard shortcuts

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