value

package
v4.27.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxInt = maxUint >> 1

	MinInt = ^int64(MaxInt)
)

Variables

This section is empty.

Functions

func IClone

func IClone(root any) any

IClone performs a deep copy of a generic value.

func ICompare

func ICompare(left, right any) bool

ICompare returns true if both the left and right are equal according to one of the following conditions:

- The types exactly match and have the same value - The types are both either a string or byte slice and the underlying data is the same - The types are both numerical and have the same value - Both types are a matching slice or map containing values matching these same conditions.

func IGetBool

func IGetBool(v any) (bool, error)

IGetBool takes a boxed value and attempts to extract a boolean from it.

func IGetBytes

func IGetBytes(v any) ([]byte, error)

IGetBytes takes a boxed value and attempts to return a byte slice value. Returns an error if the value is not a string or byte slice.

func IGetFloat32

func IGetFloat32(v any) (float32, error)

IGetFloat32 takes a boxed value and attempts to extract a number (float32) from it.

func IGetInt

func IGetInt(v any) (int64, error)

IGetInt takes a boxed value and attempts to extract an integer (int64) from it.

func IGetNumber

func IGetNumber(v any) (float64, error)

IGetNumber takes a boxed value and attempts to extract a number (float64) from it.

func IGetString

func IGetString(v any) (string, error)

IGetString takes a boxed value and attempts to return a string value. Returns an error if the value is not a string or byte slice.

func IGetStringMap

func IGetStringMap(v any) (map[string]string, error)

func IGetTimestamp

func IGetTimestamp(v any) (time.Time, error)

IGetTimestamp takes a boxed value and attempts to coerce it into a timestamp, either by interpretting a numerical value as a unix timestamp, or by parsing a string value as RFC3339Nano.

func IGetUInt

func IGetUInt(v any) (uint64, error)

IGetUInt takes a boxed value and attempts to extract an unsigned integer (uint64) from it.

func IIsNull

func IIsNull(i any) bool

IIsNull returns whether a bloblang type is null, this includes Delete and Nothing types.

func ISanitize

func ISanitize(i any) any

ISanitize takes a boxed value of any type and attempts to convert it into one of the following types: string, []byte, int64, uint64, float64, bool, []interface{}, map[string]interface{}, Delete, Nothing.

func IToBool

func IToBool(v any) (bool, error)

IToBool takes a boxed value and attempts to extract a boolean from it or parse it into a bool.

func IToBytes

func IToBytes(i any) []byte

IToBytes takes a boxed value of any type and attempts to convert it into a byte slice.

func IToFloat32

func IToFloat32(v any) (float32, error)

IToFloat32 takes a boxed value and attempts to extract a number (float32) from it or parse one.

func IToFloat64

func IToFloat64(v any) (float64, error)

IToFloat64 takes a boxed value and attempts to extract a number (float64) from it or parse one.

func IToInt

func IToInt(v any) (int64, error)

IToInt takes a boxed value and attempts to extract a number (int64) from it or parse one.

func IToInt16

func IToInt16(v any) (int16, error)

IToInt16 takes a boxed value and attempts to extract a number (int64) from it or parse one.

func IToInt32

func IToInt32(v any) (int32, error)

IToInt32 takes a boxed value and attempts to extract a number (int32) from it or parse one.

func IToInt8

func IToInt8(v any) (int8, error)

IToInt8 takes a boxed value and attempts to extract a number (int8) from it or parse one.

func IToNumber

func IToNumber(v any) (float64, error)

IToNumber takes a boxed value and attempts to extract a number (float64) from it or parse one.

func IToString

func IToString(i any) string

IToString takes a boxed value of any type and attempts to convert it into a string.

func IToUint

func IToUint(v any) (uint64, error)

IToUint takes a boxed value and attempts to extract a number (uint64) from it or parse one.

func IToUint16

func IToUint16(v any) (uint16, error)

IToUint16 takes a boxed value and attempts to extract a number (uint16) from it or parse one.

func IToUint32

func IToUint32(v any) (uint32, error)

IToUint32 takes a boxed value and attempts to extract a number (uint32) from it or parse one.

func IToUint8

func IToUint8(v any) (uint8, error)

IToUint8 takes a boxed value and attempts to extract a number (uint8) from it or parse one.

func RestrictForComparison

func RestrictForComparison(v any) any

Types

type Delete

type Delete *struct{}

Delete is a special type that serializes to `null` when forced but indicates a target should be deleted.

type Nothing

type Nothing *struct{}

Nothing is a special type that serializes to `null` when forced but indicates a query should be disregarded (and not mapped).

type Type

type Type string

Type represents a discrete value type supported by Bloblang queries.

var (
	TString    Type = "string"
	TBytes     Type = "bytes"
	TNumber    Type = "number"
	TBool      Type = "bool"
	TTimestamp Type = "timestamp"
	TArray     Type = "array"
	TObject    Type = "object"
	TNull      Type = "null"
	TDelete    Type = "delete"
	TNothing   Type = "nothing"
	TQuery     Type = "query expression"
	TUnknown   Type = "unknown"

	// Specialised and not generally known over ValueNumber.
	TInt   Type = "integer"
	TFloat Type = "float"
)

ValueType variants.

func ITypeOf

func ITypeOf(i any) Type

ITypeOf returns the type of a boxed value as a discrete ValueType. If the type of the value is unknown then ValueUnknown is returned.

type TypeError

type TypeError struct {
	From     string
	Expected []Type
	Actual   Type
	Value    string
}

TypeError represents an error where a value of a type was required for a function, method or operator but instead a different type was found.

func NewTypeError

func NewTypeError(value any, exp ...Type) *TypeError

NewTypeError creates a new type error.

func NewTypeErrorFrom

func NewTypeErrorFrom(from string, value any, exp ...Type) *TypeError

NewTypeErrorFrom creates a new type error with an annotation of the query that provided the wrong type.

func (*TypeError) Error

func (t *TypeError) Error() string

Error implements the standard error interface for TypeError.

Jump to

Keyboard shortcuts

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