unitchecker

Imports

Imports #

"encoding/gob"
"encoding/json"
"flag"
"fmt"
"go/ast"
"go/build"
"go/importer"
"go/parser"
"go/token"
"go/types"
"io"
"log"
"os"
"path/filepath"
"reflect"
"sort"
"strings"
"sync"
"time"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/internal/analysisflags"
"golang.org/x/tools/internal/analysisinternal"
"golang.org/x/tools/internal/facts"

Constants & Variables

exportFacts var #

These four hook variables are a proof of concept of a future parameterization of a unitchecker API that allows the client to determine how and where facts and types are produced and consumed. (Note that the eventual API will likely be quite different.) The defaults honor a Config in a manner compatible with 'go vet'.

var exportFacts = *ast.FuncLit

exportTypes var #

These four hook variables are a proof of concept of a future parameterization of a unitchecker API that allows the client to determine how and where facts and types are produced and consumed. (Note that the eventual API will likely be quite different.) The defaults honor a Config in a manner compatible with 'go vet'.

var exportTypes = *ast.FuncLit

makeFactImporter var #

These four hook variables are a proof of concept of a future parameterization of a unitchecker API that allows the client to determine how and where facts and types are produced and consumed. (Note that the eventual API will likely be quite different.) The defaults honor a Config in a manner compatible with 'go vet'.

var makeFactImporter = *ast.FuncLit

makeTypesImporter var #

These four hook variables are a proof of concept of a future parameterization of a unitchecker API that allows the client to determine how and where facts and types are produced and consumed. (Note that the eventual API will likely be quite different.) The defaults honor a Config in a manner compatible with 'go vet'.

var makeTypesImporter = *ast.FuncLit

Type Aliases

factImporter type #

type factImporter func(pkgPath string) ([]byte, error)

importerFunc type #

type importerFunc func(path string) (*types.Package, error)

Structs

Config struct #

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".

type Config struct {
ID string
Compiler string
Dir string
ImportPath string
GoVersion string
GoFiles []string
NonGoFiles []string
IgnoredFiles []string
ModulePath string
ModuleVersion string
ImportMap map[string]string
PackageFile map[string]string
Standard map[string]bool
PackageVetx map[string]string
VetxOnly bool
VetxOutput string
SucceedOnTypecheckFailure bool
}

result struct #

type result struct {
a *analysis.Analyzer
diagnostics []analysis.Diagnostic
err error
}

Functions

Import method #

func (f importerFunc) Import(path string) (*types.Package, error)

Main function #

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 Main(analyzers ...*analysis.Analyzer)

Run function #

Run reads the *.cfg file, runs the analysis, and calls os.Exit with an appropriate error code. It assumes flags have already been set.

func Run(configFile string, analyzers []*analysis.Analyzer)

readConfig function #

func readConfig(filename string) (*Config, error)

run function #

func run(fset *token.FileSet, cfg *Config, analyzers []*analysis.Analyzer) ([]result, error)

Generated with Arrow