path

package
v0.0.0-...-81b44d8 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 13 Imported by: 0

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

View Source
const DefaultGopkgFile = "gopkg.yaml"

DefaultGopkgFile is the default name for the gopkg.yaml file.

View Source
const LockFile = "gopkg.lock"

LockFile is the default name for the lock file.

Variables

View Source
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.

View Source
var Tmp = ""

Tmp is the temporary directory Gopkg should use. Defaults to "" which signals using the system default.

View Source
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

func CopyDir(source string, dest string) error

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

func CopyFile(source string, dest string) error

CopyFile copies a source file to a destination.

It follows symbolic links and retains modes.

func CustomRemoveAll

func CustomRemoveAll(p string) error

CustomRemoveAll is similar to os.RemoveAll but deals with the bug outlined at https://github.com/golang/go/issues/20841.

func CustomRename

func CustomRename(o, n string) error

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 Gopkg

func Gopkg() (string, error)

Gopkg gets the path to the closest gopkg file.

func GopkgWD

func GopkgWD(dir string) (string, error)

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 HasLock

func HasLock(basepath string) bool

HasLock returns true if this can stat a lockfile at the givin location.

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

func IsDirectoryEmpty(dir string) (bool, error)

IsDirectoryEmpty checks if a directory is empty.

func IsLink(fi os.FileInfo) bool

IsLink returns true if the given FileInfo references a link.

func SetHome

func SetHome(h string)

SetHome sets the home directory for Gopkg.

func StripBasepath

func StripBasepath(p string) string

StripBasepath removes the base directory from a passed in path.

func StripVendor

func StripVendor() error

StripVendor removes nested vendor and Godeps/_workspace/ directories.

func Vendor

func Vendor() (string, error)

Vendor calculates the path to the vendor directory.

Based on working directory, VendorDir and GopkgFile, this attempts to guess the location of the vendor directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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