tools: golang.org/x/tools/go/analysis/passes/pkgfact Index | Files

package pkgfact

import "golang.org/x/tools/go/analysis/passes/pkgfact"

The pkgfact package is a demonstration and test of the package fact mechanism.

The output of the pkgfact analysis is a set of key/values pairs gathered from the analyzed package and its imported dependencies. Each key/value pair comes from a top-level constant declaration whose name starts and ends with "_". For example:

     package p

	const _greeting_  = "hello"
	const _audience_  = "world"

the pkgfact analysis output for package p would be:

{"greeting": "hello", "audience": "world"}.

In addition, the analysis reports a diagnostic at each import showing which key/value pairs it contributes.

Index

Package Files

pkgfact.go

Variables

var Analyzer = &analysis.Analyzer{
    Name:       "pkgfact",
    Doc:        "gather name/value pairs from constant declarations",
    Run:        run,
    FactTypes:  []analysis.Fact{new(pairsFact)},
    ResultType: reflect.TypeOf(map[string]string{}),
}

Package pkgfact imports 8 packages (graph) and is imported by 1 packages. Updated 2019-11-15. Refresh now. Tools for package owners.