...
Package unitchecker
import "cmd/vendor/golang.org/x/tools/go/analysis/unitchecker"
- Overview
- Index
The unitchecker package defines the main function for an analysis
driver that analyzes a single compilation unit during a build.
It is invoked by a build system such as "go vet":
$ go vet -vettool=$(which vet)
It supports the following command-line protocol:
-V=full describe executable (to the build tool)
-flags describe flags (to the build tool)
foo.cfg description of compilation unit (from the build tool)
This package does not depend on go/packages.
If you need a standalone tool, use multichecker,
which supports this mode but can also load packages
from source using go/packages.
In the call graph viewer below, each node
is a function belonging to this package
and its children are the functions it
calls—perhaps dynamically.
The root nodes are the entry points of the
package: functions that may be called from
outside the package.
There may be non-exported or anonymous
functions among them if they are called
dynamically from another package.
Click a node to visit that function's source code.
From there you can visit its callers by
clicking its declaring func
token.
Functions may be omitted if they were
determined to be unreachable in the
particular programs or tests that were
analyzed.
func Main(analyzers ...*analysis.Analyzer)
Main is the main function of a vet-like analysis tool that must be
invoked by a build system to analyze a single package.
The protocol required by 'go vet -vettool=...' is that the tool must support:
-flags describe flags in JSON
-V=full describe executable for build caching
foo.cfg perform separate modular analyze on the single
unit described by a JSON config file foo.cfg.
func Run(configFile string, analyzers []*analysis.Analyzer)
Run reads the *.cfg file, runs the analysis,
and calls os.Exit with an appropriate error code.
It assumes flags have already been set.
type Config struct {
ID string
Compiler string
Dir string
ImportPath string
GoFiles []string
NonGoFiles []string
ImportMap map[string]string
PackageFile map[string]string
Standard map[string]bool
PackageVetx map[string]string
VetxOnly bool
VetxOutput string
SucceedOnTypecheckFailure bool
}
A Config describes a compilation unit to be analyzed.
It is provided to the tool in a JSON-encoded file
whose name ends with ".cfg".