keyorder

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package keyorder remembers the key order of objects decoded from input, so encoders can write objects that a query passes through unchanged in their original order.

Order is attached to a specific map value, not to its contents. gojq builds a new map for any object a query creates or modifies, and such maps have no recorded order, so encoders fall back to sorted keys for them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Disable

func Disable()

Disable discards the registry. Encoders return to sorted keys.

func Enable

func Enable()

Enable starts a new, empty registry and begins recording.

func Enabled

func Enabled() bool

Enabled reports whether encoders should write keys in recorded order.

func Keys

func Keys(m map[string]any) []string

Keys returns the keys of m in recorded order, followed by any keys that have no recorded position, sorted. Without a recorded order all keys are sorted.

func Record

func Record(m map[string]any, keys []string)

Record sets the key order of m. keys may contain duplicates or keys that are not in m; Keys ignores both.

func RecordRows

func RecordRows(rows any, keys []string)

RecordRows sets keys as the order of every object in rows, for formats where one header row orders all records.

func Recording

func Recording() bool

Recording reports whether decoders should record key order.

func StopRecording

func StopRecording()

StopRecording keeps the recorded orders but ignores later Record calls, so decoding done after the input is read, such as re-parsing output for raw formatting, does not grow the registry.

Types

This section is empty.

Jump to

Keyboard shortcuts

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