1
0
mirror of https://github.com/golang/go synced 2024-11-05 14:56:10 -07:00

go/analysis: gofmt snippets in package documentation

Tab widths may vary, making tabs suitable for indentation but
not alignment. Use spaces for alignment instead, as gofmt does.

This improves the readability of the package comment on pkg.go.dev.

While here, also make use of blank lines more consistent: two blank
lines before a heading, and a single blank line everywhere else.

Change-Id: I6b6a67b413d02066e2ce233f09d49c1ccdf28a84
Reviewed-on: https://go-review.googlesource.com/c/tools/+/209457
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Dmitri Shuralyov 2019-11-30 17:56:20 -05:00
parent a0e659d513
commit 53d48bfcf5

View File

@ -3,6 +3,7 @@
The analysis package defines the interface between a modular static
analysis and an analysis driver program.
Background
A static analysis is a function that inspects a package of Go code and
@ -41,9 +42,9 @@ the go/analysis/passes/ subdirectory:
package unusedresult
var Analyzer = &analysis.Analyzer{
Name: "unusedresult",
Doc: "check for unused results of calls to some functions",
Run: run,
Name: "unusedresult",
Doc: "check for unused results of calls to some functions",
Run: run,
...
}
@ -51,7 +52,6 @@ the go/analysis/passes/ subdirectory:
...
}
An analysis driver is a program such as vet that runs a set of
analyses and prints the diagnostics that they report.
The driver program must import the list of Analyzers it needs.
@ -107,14 +107,14 @@ multiple analyzers. It is based on the multichecker package
The Analyzer type has more fields besides those shown above:
type Analyzer struct {
Name string
Doc string
Flags flag.FlagSet
Run func(*Pass) (interface{}, error)
RunDespiteErrors bool
ResultType reflect.Type
Requires []*Analyzer
FactTypes []Fact
Name string
Doc string
Flags flag.FlagSet
Run func(*Pass) (interface{}, error)
RunDespiteErrors bool
ResultType reflect.Type
Requires []*Analyzer
FactTypes []Fact
}
The Flags field declares a set of named (global) flag variables that
@ -154,13 +154,13 @@ package being analyzed, and provides operations to the Run function for
reporting diagnostics and other information back to the driver.
type Pass struct {
Fset *token.FileSet
Files []*ast.File
OtherFiles []string
Pkg *types.Package
TypesInfo *types.Info
ResultOf map[*Analyzer]interface{}
Report func(Diagnostic)
Fset *token.FileSet
Files []*ast.File
OtherFiles []string
Pkg *types.Package
TypesInfo *types.Info
ResultOf map[*Analyzer]interface{}
Report func(Diagnostic)
...
}
@ -245,7 +245,7 @@ package.
An Analyzer that uses facts must declare their types:
var Analyzer = &analysis.Analyzer{
Name: "printf",
Name: "printf",
FactTypes: []analysis.Fact{new(isWrapper)},
...
}
@ -330,7 +330,5 @@ entirety as:
A tool that provides multiple analyzers can use multichecker in a
similar way, giving it the list of Analyzers.
*/
package analysis