gvisorgvisor.dev/gvisor/tools/nogo/facts Index | Files

package facts

import "gvisor.dev/gvisor/tools/nogo/facts"

Package facts implements alternate fact types.

Index

Types

type Bundle

type Bundle struct {
	// contains filtered or unexported fields
}

Bundle is a set of facts about different packages.

This is used to serialize a collection of facts about different packages, which will be loaded and evaluated lazily.

func BundleFrom

func BundleFrom(filename string) (*Bundle, error)

BundleFrom may be used to create a new bundle that deserializes the contents of the given file.

Note that there is no explicit close mechanism, and the underlying file will be closed only when the object is finalized.

func NewBundle

func NewBundle() *Bundle

NewBundle makes a new package bundle.

func (*Bundle) Add

func (b *Bundle) Add(path string, facts *Package)

Add adds the package to the Bundle.

func (*Bundle) Package

func (b *Bundle) Package(pkg *types.Package) (*Package, error)

Package looks up the given package in the bundle.

func (*Bundle) Serialize

func (b *Bundle) Serialize(w io.Writer) error

Serialize implements Serializer.Serialize.

type Package

type Package struct {
	Objects map[types.Object][]analysis.Fact
}

Package is a set of facts about a single package.

These use the types.Object as the key because this is canonical. Normally, this is canonical only in the context of a single types.Package. However, because all imports are shared across all packages, there is a single canonical types.Object shared among all packages being analyzed.

func NewPackage

func NewPackage() *Package

NewPackage returns a new set of Package facts.

func (*Package) ExportFact

func (p *Package) ExportFact(obj types.Object, ptr analysis.Fact)

ExportFact exports an object fact.

func (*Package) ImportFact

func (p *Package) ImportFact(obj types.Object, ptr analysis.Fact) bool

ImportFact imports an object fact.

func (*Package) ReadFrom

func (p *Package) ReadFrom(pkg *types.Package, r io.Reader) error

ReadFrom deserializes a package.

func (*Package) Serialize

func (p *Package) Serialize(w io.Writer) error

Serialize implements Serializer.Serialize.

type Serializer

type Serializer interface {
	Serialize(w io.Writer) error
}

Serializer is used for fact serialization.

It generalizes over the Package and Bundle types.

Source Files

facts.go

Version
v0.0.0-20250617221512-95d875276806 (latest)
Published
Jun 17, 2025
Platform
linux/amd64
Imports
9 packages
Last checked
11 hours ago

Tools for package owners.