fieldprobe

package
v0.196.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 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 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

func Fill(ptr any, overrides map[string]any)

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

func Lost(want, got any) []string

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.

func Unset

func Unset(v any) []string

Unset names, in order, every exported field reachable from v that holds its zero value, by its path from the top, following pointers, slices and maps the way Lost does. A nil pointer, an empty slice and an empty map are named whole.

Types

This section is empty.

Jump to

Keyboard shortcuts

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