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

format

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package format renders check reports for the `check` command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DepReleaseURL

func DepReleaseURL(dep string, isTagObject TagObjectCheck) string

DepReleaseURL derives a GitHub URL from a dep key of the form "owner/repo[/path]@ref". Commit-SHA pins link to /commit/<sha> (the diff view). Annotated-tag-object SHAs link to /tree/<sha> instead — /commit/<tagobject-sha> returns 404 because the tag object is not a commit. Non-SHA refs link to /releases/tag/<ref>. A nil isTagObject (or one that returns false) falls back to the plain /commit/<sha> path.

func IsAlertedCategory

func IsAlertedCategory(c checks.Category) bool

IsAlertedCategory reports whether a finding category has no auto-fix and requires human investigation (already surfaced in PresentResults — the remediator should not re-print it in non-interactive mode).

func PresentResults

func PresentResults(out *ui.UI, report *checks.Report, valid bool, willRemediate bool)

PresentResults renders human-readable output from a check report.

Warning surfaces (RepoFindings, ParseWarnings, not-pinned, sha-as-ref, ref-moved, inconclusive) use the Term* family so they reach the terminal even when check.go has routed the narration log to io.Discard. The error block and the "All N valid" success line still use narration helpers — both are re-rendered by check.go's post-remediation Term* summary, so we'd duplicate output if we surfaced them here too.

func ValidateJSONFields

func ValidateJSONFields(fieldsCSV string) error

ValidateJSONFields checks that every comma-separated entry in fieldsCSV is a recognized --json output field. An empty selection is valid (no JSON output requested). Wire this into a command's PreRunE so a bad --json list is rejected before any workflow or lockfile mutation runs, instead of failing late in WriteJSON after side effects.

func WorkflowsForDep

func WorkflowsForDep(report *checks.Report, depKey string) []string

WorkflowsForDep returns workflow paths whose findings reference the given dependency key (ordered as they appear in the report, deduplicated).

func WriteJSON

func WriteJSON(w io.Writer, report *checks.Report, valid bool, fieldsCSV, cliVersion, lockfileVersion string) error

WriteJSON writes the unified JSON output for `check --json`. fieldsCSV is the comma-separated user selection (e.g. "valid,findings,workflows"). cliVersion and lockfileVersion are emitted as top-level fields so consumers can pin behavior to a known schema.

Types

type Dependency

type Dependency struct {
	NWO        string   `json:"nwo"`
	Ref        string   `json:"ref"`
	SHA        string   `json:"sha"`
	HashAlgo   string   `json:"hash_algo,omitempty"`
	Direct     bool     `json:"direct"`
	RequiredBy []string `json:"required_by,omitempty"`
}

Dependency is the JSON-safe view of a resolved dependency, deduplicated across workflows in the JSON output.

type Finding

type Finding struct {
	Workflow    string `json:"workflow"`
	Category    string `json:"category"`
	Severity    string `json:"severity"`
	Confidence  string `json:"confidence,omitempty"`
	Dependency  string `json:"dependency,omitempty"`
	RequiredBy  string `json:"required_by,omitempty"`
	Detail      string `json:"detail"`
	Remediation string `json:"remediation,omitempty"`
	DocURL      string `json:"doc_url,omitempty"`
}

Finding is the JSON-safe view of a checks.Finding.

type TagObjectCheck

type TagObjectCheck func(owner, repo, sha string) bool

TagObjectCheck reports whether the given SHA is a known annotated-tag object in owner/repo. Used by DepReleaseURL so it can pick /tree/<sha> over /commit/<sha> for tag objects (which 404 under /commit/). Pass nil to skip the check and always use /commit/<sha>. *resolve.Resolver's IsKnownTagObject method satisfies the signature directly.

type Workflow

type Workflow struct {
	Path         string       `json:"path"`
	Valid        bool         `json:"valid"`
	Findings     []Finding    `json:"findings"`
	Dependencies []Dependency `json:"dependencies,omitempty"`
}

Workflow is the JSON-safe view of a single workflow's findings and dependencies.

Jump to

Keyboard shortcuts

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