Imports #
"go/ast"
"go/parser"
"go/token"
"strings"
"unicode"
"unicode/utf8"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
"go/ast"
"go/parser"
"go/token"
"strings"
"unicode"
"unicode/utf8"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/passes/internal/analysisutil"
var Analyzer = *ast.UnaryExpr
const Doc = `check Go toolchain directives such as //go:debug
This analyzer checks for problems with known Go toolchain directives
in all Go source files in a package directory, even those excluded by
//go:build constraints, and all non-Go source files too.
For //go:debug (see https://go.dev/doc/godebug), the analyzer checks
that the directives are placed only in Go source files, only above the
package comment, and only in package main or *_test.go files.
Support for other known directives may be added in the future.
This analyzer does not check //go:build, which is handled by the
buildtag analyzer.
`
type checker struct {
pass *analysis.Pass
filename string
file *ast.File
inHeader bool
}
func checkGoFile(pass *analysis.Pass, f *ast.File)
func checkOtherFile(pass *analysis.Pass, filename string) error
func (check *checker) comment(pos token.Pos, line string)
func newChecker(pass *analysis.Pass, filename string, file *ast.File) *checker
func (check *checker) nonGoFile(pos token.Pos, fullText string)
func runDirective(pass *analysis.Pass) (interface{}, error)
Go 1.20 strings.CutPrefix.
func stringsCutPrefix(s string, prefix string) (after string, found bool)
Generated with Arrow