util

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFalse

func IsFalse(value interface{}) bool

IsFalse determines if an object is false based on the JMESPath spec. JMESPath defines false values to be any of: - An empty string array, or hash. - The boolean value false. - nil.

func IsSliceType

func IsSliceType(v interface{}) bool

func Max

func Max[T constraints.Ordered](a T, b T) T

func Min

func Min[T constraints.Ordered](a T, b T) T

func ObjsEqual

func ObjsEqual(left interface{}, right interface{}) bool

ObjsEqual is a generic object equality check. It will take two arbitrary objects and recursively determine if they are equal.

func Slice

func Slice[T interface{} | rune](slice []T, parts []SliceParam) ([]T, error)

Slice supports [start:stop:step] style slicing that's supported in JMESPath.

func ToArrayArray

func ToArrayArray(data interface{}) ([][]interface{}, bool)

ToArrayArray converts an empty interface type to a slice of slices. If any element in the array cannot be converted, then nil is returned along with a second value of false.

func ToArrayNum

func ToArrayNum(data interface{}) ([]float64, bool)

ToArrayNum converts an empty interface type to a slice of float64. If any element in the array cannot be converted, then nil is returned along with a second value of false.

func ToArrayStr

func ToArrayStr(data interface{}) ([]string, bool)

ToArrayStr converts an empty interface type to a slice of strings. If any element in the array cannot be converted, then nil is returned along with a second value of false. If the input data could be entirely converted, then the converted data, along with a second value of true, will be returned.

func ToInteger

func ToInteger(v interface{}) (int, bool)

ToInteger converts an empty interface to a integer. It expects the empty interface to represent a float64 JSON number. If the empty interface cannot be converted or if the number is not an integer, the function returns a second boolean value false.

func ToPositiveInteger

func ToPositiveInteger(v interface{}) (int, bool)

Types

type SliceParam

type SliceParam struct {
	N         int
	Specified bool
}

SliceParam refers to a single part of a slice. A slice consists of a start, a stop, and a step, similar to python slices.

func MakeSliceParams

func MakeSliceParams(parts []*int) []SliceParam

Jump to

Keyboard shortcuts

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