There are several ways to traverse values from looking up based on path to iteration and walking the value tree. Some of these are configurable, which is tied to the different labels like regular, hidden, optional, and definitions.
We will use the following Value for the examples in this section.
Selectors and MakePath
We saw how to use
ParsePath in a previous section.
We can programmatically construct paths with
We’ll also use this to reconstruct the label for the current value.
You will likely want to make choices based on the type of a value.
Use a switch statement on
Walking a Value
In the previous example for default walk, some of the fields were not traversed.
This is because CUE’s default
Walk() uses the same default
Field() options on a value.
In order to walk all fields, we need to write a custom walk function
where we can pass in the options for