Documentation ¶
Index ¶
- func GetPackagePaths(gopath string, path string) ([]string, error)
- func GetTypePackagePath(t types.Type) string
- func GetTypeShortName(t types.Type) string
- func IsStandardPackage(p string) bool
- func IsSubPackage(p string, rootPackage string) bool
- func IsVendorPackage(p string, rootPackage string) bool
- type Leak
- type Leaks
- type Option
- type PackageInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPackagePaths ¶
GetPackagePaths returns the package paths for the packages matching the specified `path`.
If `path` is a Go package path, is it returned as-is. This is a convenience.
If `path` is either an absolute file path, or starts with a dot, the specified `gopath` is used to determine the package paths.
If the file `path` is not in `gopath` or if it's relative position to the `gopath` can't be determined, an error is returned.
If `path` is a filepath and ends with ..., subpackages are also looked for recursively.
GetPackagePaths does not check for the package existence and will hapilly return a package path for a non-existing package.
func GetTypePackagePath ¶
GetTypePackagePath returns the package path for a given type.
For built-in types (int, string, ...), an empty string is returned.
func GetTypeShortName ¶
GetTypeShortName returns the short type representation for a given type.
func IsStandardPackage ¶
IsStandardPackage checks whether a given package is standard.
Standard packages are provided with Go.
func IsSubPackage ¶
IsSubPackage checks whether a given package is a subpackage of the specified root package.
A package is always a subpackage of itself.
func IsVendorPackage ¶
IsVendorPackage checks whether a given package is a vendor of the specified root package.
A vendor is located in a `/vendor/` directory.
Types ¶
type Leak ¶
type Leak struct { Object types.Object Position token.Position // contains filtered or unexported fields }
Leak represents a leaking type.
type Leaks ¶
type Leaks []Leak
Leaks represents a slice of Leak instances.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option represents an option for PackageInfo.
func UseVCSRootOption ¶
UseVCSRootOption returns an option that uses the VCS root as a package root.
type PackageInfo ¶
type PackageInfo struct { Package *types.Package Info types.Info Fset *token.FileSet VCSRoot string }
PackageInfo represents information about a package.
func GetPackageInfo ¶
func GetPackageInfo(p string, options ...Option) (PackageInfo, error)
GetPackageInfo returns information about the package at the specified location.
func (PackageInfo) CheckLeaks ¶
func (i PackageInfo) CheckLeaks(t types.Type) error
CheckLeaks checks wheter a specified type is being leaked.
func (PackageInfo) GetRoot ¶
func (i PackageInfo) GetRoot() string
GetRoot gets the root of the package.
func (PackageInfo) IsMain ¶
func (i PackageInfo) IsMain() bool
IsMain checks whether the package is a main package.
func (PackageInfo) Leaks ¶
func (i PackageInfo) Leaks() (result Leaks)
Leaks returns the leaks in the package.