Help us shape the future of Go! Take the 2026 Go Developer Survey

navigation

package
v0.0.0-...-c0bffe4 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package navigation reads a JSON pointer through the library's parsed model as jsonpointer.GetTarget's walk reads it, and says where that walk leaves the model for the raw YAML an object was built from. Tests such as TestWalk_AnswersAsTheWholeReadDoes hold each reading to the library's.

The library finds a key in raw YAML by comparing a mapping's keys in order, taking a repeated one's first (docs/parser-library.md#duplicate-key), so a reader asking it once per reference pays the square of a wide mapping (GitHub #778). Knowing where the walk leaves the model lets a reader stop there, or read on through an index.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsIndex

func IsIndex(token string) bool

IsIndex reports whether the library types token as an index: ASCII digits, with no leading zero unless the token is "0". It reads a token alike escaped or decoded, since no escape decodes to a digit.

func Step

func Step(node any, token string) (any, bool)

Step returns what node holds under the one token, as the library's walk reads it on to the next, and false where it holds nothing. Only the empty token is read below an envelope keyed by the empty string, since the library reads the pointer "/" as the root; on raw YAML the empty token still answers the node itself. A model held by value, such as an operation's responses, comes back as a pointer to a copy: the walk reads on from its address, where its methods navigate it (GitHub #779).

func Tokens

func Tokens(pointer jsontext.Pointer) ([]string, bool)

Tokens returns the tokens of pointer as the library's walk compares them, each decoded, and none for "/", which the library reads as the root where jsontext reads one empty token. It reports false for a pointer the library refuses before reading anything.

Types

type Reading

type Reading int

Reading is how the library's read of one token from a node goes on.

const (
	// Answering is a read a field or an entry answers, or that fails there.
	Answering Reading = iota
	// Leaving is a read of the token, and the rest after it, in raw YAML.
	Leaving
	// Retried is a read of an index token as a key with the rest below it,
	// and as an index once that fails, so what answers it turns on the rest.
	Retried
)

func ReadingOf

func ReadingOf(node any, token string) (Reading, *yaml.Node)

ReadingOf returns how the library's read of token from node goes on, and the raw YAML it is read in where it leaves the model, with the tokens after it: node itself when it is raw YAML, else the mapping an object was built from where none of its fields or embedded maps answers token. It follows the library's dispatch for one token (getStructTarget, navigateModel), asking each map the library asks through the map's own method.

Jump to

Keyboard shortcuts

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