pkgpath

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: BSD-3-Clause Imports: 10 Imported by: 31

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGoPkgExcludeMatcher

func DefaultGoPkgExcludeMatcher() matcher.Matcher

DefaultGoPkgExcludeMatcher returns a matcher that matches names that standard Go tools generally exclude as Go packages. This includes hidden directories, directories named "testdata" and directories that start with an underscore.

Types

type Packages

type Packages interface {
	RootDir() string
	Packages(pathType Type) (map[string]string, error)
	Paths(pathType Type) ([]string, error)
	Filter(exclude matcher.Matcher) (Packages, error)
}

func PackagesFromPaths

func PackagesFromPaths(rootDir string, relPaths []string) (Packages, error)

PackagesFromPaths creates a Packages using the provided relative paths. If any of the relative paths end in a splat ("/..."), then all of the sub-directories of that directory are also considered.

func PackagesInDir

func PackagesInDir(rootDir string, exclude matcher.Matcher) (Packages, error)

PackagesInDir creates a Packages that contains all of the packages rooted at the provided directory. Every directory rooted in the provided directory whose path does not match the provided exclude matcher is considered as a package.

type PkgPather

type PkgPather interface {
	Abs() string
	GoPathSrcRel() (string, error)
	Rel(root string) (string, error)
}

func NewAbsPkgPath

func NewAbsPkgPath(absPath string) PkgPather

func NewGoPathSrcRelPkgPath

func NewGoPathSrcRelPkgPath(goPathSrcRelPath string) PkgPather

func NewRelPkgPath

func NewRelPkgPath(relPath, baseDir string) PkgPather

type Type

type Type int
const (
	// Absolute is the absolute path to a package, e.g.: /Volumes/git/go/src/github.com/org/project
	Absolute Type = iota
	// GoPathSrcRelative is the path to a package relative to "$GOPATH/src", e.g.: github.com/org/project. Is the
	// file path rather than the import path, so includes vendor directories in path, e.g.:
	// github.com/org/project/vendor/github.com/other/project
	GoPathSrcRelative
	// Relative is the relative path to a package relative to a directory. Always includes the "./" prefix, e.g.:
	// ./., ./app/main.
	Relative
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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