v0.7.0

utils Package

Last updated

This page lists the exported helpers of core/utils, which convert between command text and decoded JSON values and walk nested paths.

Functions

import "github.com/pardnchiu/toriidb/core/utils"

func WalkKeys(obj any, subKeys []string) (any, bool)
func Atov(text string) any
func Vtoa(value any) string
func Vtof(value any) (float64, bool)
Function Behavior Used by
utils.WalkKeys Follows subKeys through decoded JSON: a map[string]any by field name, a []any by decimal index. Returns false for a missing field, a non-numeric, negative, or out-of-range index, or a scalar in the middle of the path. An empty subKeys returns obj itself GetField, IncrField, filter.Cond
utils.Atov Converts command text to a JSON value: null → nil, true/false → bool, integer → int64, other number → float64, trimmed {...}/[...] that parses → object or array, anything else → string SetField
utils.Vtoa Renders a decoded value as text: nil → (nil), whole float64 without a decimal point, other float64 in shortest form, bool as true/false, objects and arrays as compact JSON, other types with %v GetField, Incr, Exec, filter.Cond
utils.Vtof Returns a number as float64 for float64 and int64 inputs; any other type, including numeric strings, returns false IncrField

Round-Trip Rules

中文