depbleed

package
v0.0.0-...-10f7748 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2017 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPackagePaths

func GetPackagePaths(gopath string, path string) ([]string, error)

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

func GetTypePackagePath(t types.Type) string

GetTypePackagePath returns the package path for a given type.

For built-in types (int, string, ...), an empty string is returned.

func GetTypeShortName

func GetTypeShortName(t types.Type) string

GetTypeShortName returns the short type representation for a given type.

func IsStandardPackage

func IsStandardPackage(p string) bool

IsStandardPackage checks whether a given package is standard.

Standard packages are provided with Go.

func IsSubPackage

func IsSubPackage(p string, rootPackage string) bool

IsSubPackage checks whether a given package is a subpackage of the specified root package.

A package is always a subpackage of itself.

func IsVendorPackage

func IsVendorPackage(p string, rootPackage string) bool

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.

func (Leak) Error

func (l Leak) Error() string

Error constructs an error string.

type Leaks

type Leaks []Leak

Leaks represents a slice of Leak instances.

func (Leaks) Len

func (slice Leaks) Len() int

Len gives the length of the leak slice/

func (Leaks) Less

func (slice Leaks) Less(i, j int) bool

Less returns if slice[i] should be before slice[j].

func (Leaks) Swap

func (slice Leaks) Swap(i, j int)

Swap swaps two elements.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option represents an option for PackageInfo.

func UseVCSRootOption

func UseVCSRootOption(gopath string) Option

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.

Directories

Path Synopsis
fixtures

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL