Documentation
¶
Overview ¶
Package fieldprobe fills every exported field of a value and names the fields a copy of it lost.
It is for round-trip tests of a type whose fields are written and read back by hand, field by field, in more than one place: results.sarif's property bag, report.json and the disk cache all carry a finding that way. A test that names the fields it checks passes for a field added after it was written, so a writer or reader that never learned the new field drops it with every test green. Filling by reflection instead means a new field is checked the day it is added.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fill ¶
Fill sets every exported field reachable from ptr, which must be a non-nil pointer, to a non-zero value, following pointers, slices and maps into the types they hold. A string is set to its field's path, such as "Package.Name", so a value that lands in the wrong field names where it came from; numbers count up from 1, so no two fields share one; a bool is true; a slice and a map get one element each.
Overrides sets the field at a path to a value of its own, for a field whose writer validates or rewrites what it is given, such as a level that must be one SARIF names. The value must be assignable to the field. A path names a field the way Lost does: "Escalation.From", "Reachability.Paths[0].Frames[0].Line".
func Lost ¶
Lost names, in order, every field of want whose value got does not hold, by its path from the top: "Package.Affected", "Correlation.AlsoFoundBy[0].Location". It descends into structs, pointers, slices and maps, so a field lost inside a nested value is named rather than its parent. A slice or map of a different length is named whole.
Types ¶
This section is empty.