Documentation ¶
Overview ¶
Package path contains path and environment utilities for Gopkg.
This includes tools to find and manipulate Go path variables, as well as tools for copying from one path to another.
Index ¶
- Constants
- Variables
- func Basepath() string
- func CopyDir(source string, dest string) error
- func CopyFile(source string, dest string) error
- func CustomRemoveAll(p string) error
- func CustomRename(o, n string) error
- func Gopath() string
- func Gopaths() []string
- func Gopkg() (string, error)
- func GopkgWD(dir string) (string, error)
- func HasLock(basepath string) bool
- func Home() string
- func IsDirectoryEmpty(dir string) (bool, error)
- func IsLink(fi os.FileInfo) bool
- func SetHome(h string)
- func StripBasepath(p string) string
- func StripVendor() error
- func Vendor() (string, error)
Constants ¶
const DefaultGopkgFile = "gopkg.yaml"
DefaultGopkgFile is the default name for the gopkg.yaml file.
const LockFile = "gopkg.lock"
LockFile is the default name for the lock file.
Variables ¶
var GopkgFile = DefaultGopkgFile
GopkgFile is the name of the Gopkg file.
Setting this is not concurrency safe. For consistency, it should really only be set once, at startup, or not at all.
var Tmp = ""
Tmp is the temporary directory Gopkg should use. Defaults to "" which signals using the system default.
var VendorDir = "vendor"
VendorDir is the name of the directory that holds vendored dependencies.
As of Go 1.5, this is always vendor.
Functions ¶
func Basepath ¶
func Basepath() string
Basepath returns the current working directory.
If there is an error getting the working directory, this returns ".", which should function in cases where the directory is unlinked... Then again, maybe not.
func CopyDir ¶
CopyDir copies an entire source directory to the dest directory.
This is akin to `cp -a src/* dest/`
We copy the directory here rather than jumping out to a shell so we can support multiple operating systems.
func CopyFile ¶
CopyFile copies a source file to a destination.
It follows symbolic links and retains modes.
func CustomRemoveAll ¶
CustomRemoveAll is similar to os.RemoveAll but deals with the bug outlined at https://github.com/golang/go/issues/20841.
func CustomRename ¶
CustomRename is similar to os.Rename but deals with the bug outlined at https://github.com/golang/go/issues/20841.
func Gopath ¶
func Gopath() string
Gopath gets GOPATH from environment and return the most relevant path.
A GOPATH can contain a colon-separated list of paths. This retrieves the GOPATH and returns only the FIRST ("most relevant") path.
This should be used carefully. If, for example, you are looking for a package, you may be better off using Gopaths.
func Gopaths ¶
func Gopaths() []string
Gopaths retrieves the Gopath as a list when there is more than one path listed in the Gopath.
func GopkgWD ¶
GopkgWD finds the working directory of the gopkg.yaml file, starting at dir.
If the gopkg file is not found in the current directory, it recurses up a directory.
func Home ¶
func Home() string
Home returns the Gopkg home directory ($GOPKG_HOME or ~/.gopkg, typically).
This normalizes to an absolute path, and passes through os.ExpandEnv.
func IsDirectoryEmpty ¶
IsDirectoryEmpty checks if a directory is empty.
func StripBasepath ¶
StripBasepath removes the base directory from a passed in path.
func StripVendor ¶
func StripVendor() error
StripVendor removes nested vendor and Godeps/_workspace/ directories.
Types ¶
This section is empty.