dump

package
v0.0.0-...-b915c30 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dump

func Dump(v any) any

Dump converts an arbitrary value to a scalar value.

The purpose of this function is to provide an alternative to fmt verbs such as %#v or %+v that returns a value in a more human-readable format.

  • Simple types, like numbers and strings and booleans, are returned as-is.
  • For types that implement fmt.Stringer, the result of String is returned.
  • For types that implement encoding.TextMarshaler, the result of MarshalText is returned.
  • For types that implement json.Marshaler, the result of MarshalJSON is returned. If the result is a JSON string, number, or boolean, it is converted to a Go type.
  • Byte slices and arrays are represented as hex strings.
  • For types that implement error, the result of Error is returned.
  • In maps, slices, and arrays, each element is recursively converted according to these rules and then represented as a JSON.

If a returned value is a JSON, it is returned as a json.RawMessage.

Types

This section is empty.

Jump to

Keyboard shortcuts

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