v0.0.0-...-2c5c786 Latest Latest

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0, MIT Imports: 9 Imported by: 4



Package facts implements alternate fact types.



This section is empty.


This section is empty.


This section is empty.


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.

Jump to

Keyboard shortcuts

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