Documentation
¶
Index ¶
- Variables
- func Clone[T any](v T) T
- func Equal(a, b any) bool
- func Float(v any) (float64, bool)
- func Int(v any) (int64, bool)
- func IsTrue(v any) bool
- func Kind(v any) string
- func Or(vals ...any) any
- func Quote(v any) string
- func String(v any) string
- func StringOr(v any, def string) string
- func ToFloat(v any) (float64, error)
- func ToInt(v any) (int64, error)
Constants ¶
This section is empty.
Variables ¶
var ( // Conversion failure for a value with no numeric form: a type that is not a number, text that does not parse, NaN asked for as an integer ErrNotNumber = errors.New("not a number") // Conversion failure for a number the target cannot hold: infinity or beyond the int64 range for an integer, beyond float64 for a float; the strconv sentinel ErrRange = strconv.ErrRange )
Functions ¶
func Clone ¶
func Clone[T any](v T) T
Deep copy of a value through maps, slices, arrays, pointers, objects and exported struct fields, keeping shared references shared and cycles intact
func Equal ¶
Whether two values are deeply equal: numbers by value across integer and float types, a bool only to a bool, sequences element by element, maps and objects by their entries whatever their key order (an object being a *jsonutil.Object or any value that lists its entries through Len, Get and All), values that contain themselves without looping
func Float ¶
Number a value holds when its type is a Go integer or float kind, a json.Number or a *big.Int
func Int ¶
Integer a value holds when its type is a Go integer kind, an integral json.Number or a *big.Int within int64
func IsTrue ¶
Whether a value counts as true the way Go templates test it: false for nil, false, zero numbers, empty strings, slices, maps and objects, nil pointers and anything whose Len is 0
func Kind ¶
Word for the type of a value in messages: "null", "boolean", "integer", "number", "string", "bytes", "array", "object", else the Go type
func Quote ¶
A string, a string-kind value or []byte in Go double-quoted form, anything else as String gives it
func String ¶
Text of a value: "" for nil, a string as is, []byte as text, numbers in decimal, true or false, an error's or Stringer's own text, containers as compact JSON
func ToFloat ¶
Float of a number, true and false as 1 and 0, or numeric text around which space is ignored; errors wrap ErrNotNumber (result 0) or ErrRange (result the infinity of the value's sign, as strconv.ParseFloat gives it)
Types ¶
This section is empty.