Structs
JSONDiagnostic
struct
#
A JSONDiagnostic describes the JSON schema of an analysis.Diagnostic.
TODO(matloob): include End position if present.
type JSONDiagnostic struct {
Category string `json:"category,omitempty"`
Posn string `json:"posn"`
Message string `json:"message"`
SuggestedFixes []JSONSuggestedFix `json:"suggested_fixes,omitempty"`
Related []JSONRelatedInformation `json:"related,omitempty"`
}
JSONRelatedInformation
struct
#
A JSONRelated describes a secondary position and message related to
a primary diagnostic.
TODO(adonovan): include End position if present.
type JSONRelatedInformation struct {
Posn string `json:"posn"`
Message string `json:"message"`
}
JSONSuggestedFix
struct
#
A JSONSuggestedFix describes an edit that should be applied as a whole or not
at all. It might contain multiple TextEdits/text_edits if the SuggestedFix
consists of multiple non-contiguous edits.
type JSONSuggestedFix struct {
Message string `json:"message"`
Edits []JSONTextEdit `json:"edits"`
}
JSONTextEdit
struct
#
A TextEdit describes the replacement of a portion of a file.
Start and End are zero-based half-open indices into the original byte
sequence of the file, and New is the new text.
type JSONTextEdit struct {
Filename string `json:"filename"`
Start int `json:"start"`
End int `json:"end"`
New string `json:"new"`
}
versionFlag
struct
#
versionFlag minimally complies with the -V protocol required by "go vet".
type versionFlag struct {
}
Functions
Add
method
#
Add adds the result of analysis 'name' on package 'id'.
The result is either a list of diagnostics or an error.
func (tree JSONTree) Add(fset *token.FileSet, id string, name string, diags []analysis.Diagnostic, err error)
Get
method
#
func (versionFlag) Get() interface{}
Get
method
#
triState implements flag.Value, flag.Getter, and flag.boolFlag.
They work like boolean flags: we can say vet -printf as well as vet -printf=true
func (ts *triState) Get() interface{}
Help
function
#
Help implements the help subcommand for a multichecker or unitchecker
style command. The optional args specify the analyzers to describe.
Help calls log.Fatal if no such analyzer exists.
func Help(progname string, analyzers []*analysis.Analyzer, args []string)
IsBoolFlag
method
#
func (versionFlag) IsBoolFlag() bool
IsBoolFlag
method
#
func (ts triState) IsBoolFlag() bool
Parse
function
#
Parse creates a flag for each of the analyzer's flags,
including (in multi mode) a flag named after the analyzer,
parses the flags, then filters and returns the list of
analyzers enabled by flags.
The result is intended to be passed to unitchecker.Run or checker.Run.
Use in unitchecker.Run will gob.Register all fact types for the returned
graph of analyzers but of course not the ones only reachable from
dropped analyzers. To avoid inconsistency about which gob types are
registered from run to run, Parse itself gob.Registers all the facts
only reachable from dropped analyzers.
This is not a particularly elegant API, but this is an internal package.
func Parse(analyzers []*analysis.Analyzer, multi bool) []*analysis.Analyzer
Print
method
#
func (tree JSONTree) Print(out io.Writer) error
PrintPlain
function
#
PrintPlain prints a diagnostic in plain text form.
If contextLines is nonnegative, it also prints the
offending line plus this many lines of context.
func PrintPlain(out io.Writer, fset *token.FileSet, contextLines int, diag analysis.Diagnostic)
ResolveURL
function
#
ResolveURL resolves the URL field for a Diagnostic from an Analyzer
and returns the URL. See Diagnostic.URL for details.
func ResolveURL(a *analysis.Analyzer, d analysis.Diagnostic) (string, error)
Set
method
#
func (versionFlag) Set(s string) error
Set
method
#
func (ts *triState) Set(value string) error
String
method
#
func (ts *triState) String() string
String
method
#
func (versionFlag) String() string
addVersionFlag
function
#
addVersionFlag registers a -V flag that, if set,
prints the executable version and exits 0.
If the -V flag already exists — for example, because it was already
registered by a call to cmd/internal/objabi.AddVersionFlag — then
addVersionFlag does nothing.
func addVersionFlag()
expand
function
#
func expand(analyzers []*analysis.Analyzer) map[*analysis.Analyzer]bool
isTrue
method
#
func (ts triState) isTrue() bool
printFlags
function
#
func printFlags()
triStateFlag
function
#
func triStateFlag(name string, value triState, usage string) *triState