empty

package module
v0.0.0-...-92c831e Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

README

Determine whether a library is empty or not. Built-in types are handles as follow. Use the Empty interface to extend functionality.

A value is empty if:

  • 0 for integers of any type (e.g. int, int8...etc)
  • 0.0 for floats of any type (e.g. float32, float 64)
  • maps without any keys
  • arrays with length of zero where each element satisfies its type specific empty criteria

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEmpty

func IsEmpty(any interface{}) bool

IsEmpty returns true is the value is empty, false otherwise.

func IsPresent

func IsPresent(any interface{}) bool

IsPresent returns true if the value is not empty, false otherwise.

func RegisterHandler

func RegisterHandler(valType reflect.Type, f func(interface{}) bool)

RegisterHandler registers a particular type to a function that determines whether a value of that type is empty. Useful for types that are in other libraries. However please consider using the EmptyValue interface wherever possible.

func TimeIsEmpty

func TimeIsEmpty(any interface{}) bool

TimeIsEmpty determines whether time.Time object is empty

Types

type Value

type Value interface {
	Empty() bool
}

Value is a piece of data that can either be present or not. Typically abstracts the concept of a null or empty string.

Jump to

Keyboard shortcuts

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