Documentation
¶
Overview ¶
Package analysisutil contains functions common for `analyzer` and `internal/checkers` packages. In addition, it is intended to "lighten" these packages.
If the function is common to several packages, or it makes sense to test it separately without "polluting" the target package with tests of private functionality, then you can put function in this package.
It's important to avoid dependency on `golang.org/x/tools/go/analysis` in the helpers API. This makes the API "narrower" and also allows you to test functions without some "abstraction leaks".
Index ¶
- func Imports(file *ast.File, pkgs ...string) bool
- func IsJSONLike(s string) bool
- func IsObj(typesInfo *types.Info, expr ast.Expr, expected types.Object) bool
- func IsPkg(pkg *types.Package, name, path string) bool
- func NodeBytes(fset *token.FileSet, node ast.Node) []byte
- func NodeString(fset *token.FileSet, node ast.Node) string
- func ObjectOf(pkg *types.Package, objPkg, objName string) types.Object
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Imports ¶
Imports tells if the file imports at least one of the packages. If no packages provided then function returns false.
func IsJSONLike ¶ added in v1.5.0
IsJSONLike returns true if the string has JSON format features. A positive result can be returned for invalid JSON as well.
func IsObj ¶
IsObj returns true if expression is identifier which notes to given types.Object. Useful in combination with types.Universe objects.
func IsPkg ¶
IsPkg checks that package has corresponding objName and path. Supports vendored packages.
func NodeBytes ¶
NodeBytes works as NodeString but returns a byte slice. Return nil if node AST is invalid.
func NodeString ¶
NodeString is a more powerful analogue of types.ExprString. Return empty string if node AST is invalid.
Types ¶
This section is empty.