check

package
v0.0.0-...-f98c31b Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0, BSD-3-Clause, MIT Imports: 63 Imported by: 0

Documentation

Overview

Package check implements binary analysis similar to bazel's nogo, or the unitchecker package. It exists in order to provide additional facilities for analysis, namely plumbing through the output from dumping the generated binary (to analyze actual produced code).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterStdPackages

func FilterStdPackages(srcPkgs map[string][]string) (map[string][]string, error)

FilterStdPackages returns a package source map including only packages that are also present in GOROOT.

The bazel GOROOT contains only exported packages and their dependencies.

On the other hand, srcPkgs comes from rudimentary processing of the full std sources and thus includes things like test only and experimental packages. These packages will fail to analyze without an archive in GOROOT, but we won't need those anyway, so filter them out.

func FindRoots

func FindRoots(srcs []string, srcRootRegex string) ([]string, error)

FindRoots finds a package roots.

func SplitStdPackages

func SplitStdPackages(srcs []string, srcRootPrefix string) (map[string][]string, error)

SplitStdPackages splits a std GOROOT package structure into packages.

func TemplateFuncs

func TemplateFuncs(path string, srcs []string) (map[string]any, any, error)

TemplateFuncs runs all analyzers necessary for template generation, and returns a funcmap for template rendering.

Look at facts.ResolveFuncs for a list of supported functions.

func WriteFindingsTo

func WriteFindingsTo(w io.Writer, findings FindingSet, asJSON bool) error

WriteFindingsTo serializes findings.

Types

type Finding

type Finding struct {
	Category string
	Position token.Position
	Message  string
	GOARCH   string
	GOOS     string
}

Finding is a single finding.

func (*Finding) String

func (f *Finding) String() string

String implements fmt.Stringer.String.

type FindingSet

type FindingSet []Finding

FindingSet is a collection of findings.

func Bundle

func Bundle(sources map[string][]string, roots []string) (FindingSet, facts.Serializer, error)

Bundle checks a bundle of files (typically the standard library).

roots is the set of potential GOROOT prefixes on the file paths in sources. GOROOT is effectively a merged version of these roots.

func ExtractFindingsFrom

func ExtractFindingsFrom(r io.Reader, asJSON bool) (findings FindingSet, err error)

ExtractFindingsFrom loads findings from an io.Reader.

func ExtractFindingsFromFile

func ExtractFindingsFromFile(filename string, asJSON bool) (FindingSet, error)

ExtractFindingsFromFile loads findings from a file.

func Package

func Package(path string, srcs []string) (FindingSet, facts.Serializer, error)

Package runs all analyzer on a single package.

func (FindingSet) Sort

func (fs FindingSet) Sort()

Sort sorts all findings.

Jump to

Keyboard shortcuts

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