utils

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmptyStr = ""

	ObjectType      string = "object"
	ArrayType       string = "array"
	StringType      string = "string"
	IntegerType     string = "integer"
	NumberType      string = "number"
	BooleanType     string = "boolean"
	NullType        string = "null"
	UnknownType     string = "unknown"
	NumberZeroValue int    = 0
	JSONIngest      string = "JSON.INGEST"

	GET      string = "GET"
	SET      string = "SET"
	INCRBY   string = "INCRBY"
	OVERFLOW string = "OVERFLOW"
	WRAP     string = "WRAP"
	SAT      string = "SAT"
	FAIL     string = "FAIL"
	SIGNED   string = "SIGNED"
	UNSIGNED string = "UNSIGNED"
)

Variables

This section is empty.

Functions

func AddSecondsToUnixEpoch

func AddSecondsToUnixEpoch(second int64) int64

func BoolToInt

func BoolToInt(b bool) int

func GetCurrentTime

func GetCurrentTime() time.Time

func GetJSONFieldType

func GetJSONFieldType(v interface{}) string

func IsArray

func IsArray(data any) bool

func IsFloatToIntPossible

func IsFloatToIntPossible(value float64) (int, bool)

func ParseInputJSONPath

func ParseInputJSONPath(path string) (string, bool)

This method returns the path, and a boolean value telling if the path provided follows Legacy Path Syntax or JSONPath syntax. JSON knows which syntax to use depending on the first character of the path query. If the query starts with the character $, it uses JSONPath syntax. Otherwise, it defaults to the legacy path syntax. A JSONPath query can resolve to several locations in a JSON document. In this case, the JSON commands apply the operation to every possible location. This is a major improvement over legacy path queries, which only operate on the first path.

func RoundToDecimals

func RoundToDecimals[T float32 | float64](num T, decimals int) T

RoundToDecimals rounds a float64 or float32 to a specified number of decimal places.

Types

type BitFieldOp

type BitFieldOp struct {
	Kind   string
	EType  string
	EVal   int64
	Offset int64
	Value  int64
}

func ParseBitfieldOps

func ParseBitfieldOps(args []string, readOnly bool) (ops []BitFieldOp, err error)

type Clock

type Clock interface {
	Now() time.Time
}
var (
	CurrentTime Clock = RealClock{}
)

type MockClock

type MockClock struct {
	CurrTime time.Time
}

func (*MockClock) GetTime

func (mc *MockClock) GetTime() time.Time

func (MockClock) Now

func (mc MockClock) Now() time.Time

func (*MockClock) SetTime

func (mc *MockClock) SetTime(t time.Time)

type RealClock

type RealClock struct{}

func (RealClock) Now

func (RealClock) Now() time.Time

Jump to

Keyboard shortcuts

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