Documentation
¶
Overview ¶
Package dep is a prototype dependency management library.
Index ¶
- Constants
- func BackupVendor(vpath, suffix string) (string, error)
- func ValidateProjectRoots(c *Ctx, m *Manifest, sm gps.SourceManager) error
- type Analyzer
- type Ctx
- func (c *Ctx) AbsForImport(path string) (string, error)
- func (c *Ctx) DetectProjectGOPATH(p *Project) (string, error)
- func (c *Ctx) ImportForAbs(path string) (string, error)
- func (c *Ctx) LoadProject() (*Project, error)
- func (c *Ctx) SetPaths(wd string, GOPATHs ...string) error
- func (c *Ctx) SourceManager() (*gps.SourceMgr, error)
- func (c *Ctx) ValidateParams(sm gps.SourceManager, params gps.SolveParameters) error
- type DeltaWriter
- type Lock
- type Manifest
- func (m *Manifest) DependencyConstraints() gps.ProjectConstraints
- func (m *Manifest) HasConstraintsOn(root gps.ProjectRoot) bool
- func (m *Manifest) IgnoredPackages() *pkgtree.IgnoredRuleset
- func (m *Manifest) MarshalTOML() ([]byte, error)
- func (m *Manifest) Overrides() gps.ProjectConstraints
- func (m *Manifest) RequiredPackages() map[string]bool
- type Project
- func (p *Project) FindIneffectualConstraints(sm gps.SourceManager) []gps.ProjectRoot
- func (p *Project) GetDirectDependencyNames(sm gps.SourceManager) (map[gps.ProjectRoot]bool, error)
- func (p *Project) MakeParams() gps.SolveParameters
- func (p *Project) SetRoot(root string) error
- func (p *Project) VerifyVendor() (map[string]verify.VendorStatus, error)
- type SafeWriter
- type SolveMeta
- type TreeWriter
- type VendorBehavior
Constants ¶
const LockName = "Gopkg.lock"
LockName is the lock file name used by dep.
const ManifestName = "Gopkg.toml"
ManifestName is the manifest file name used by dep.
Variables ¶
This section is empty.
Functions ¶
func BackupVendor ¶
BackupVendor looks for existing vendor directory and if it's not empty, creates a backup of it to a new directory with the provided suffix.
Types ¶
type Analyzer ¶
type Analyzer struct{}
Analyzer implements gps.ProjectAnalyzer.
func (Analyzer) DeriveManifestAndLock ¶
func (a Analyzer) DeriveManifestAndLock(path string, n gps.ProjectRoot) (gps.Manifest, gps.Lock, error)
DeriveManifestAndLock reads and returns the manifest at path/ManifestName or nil if one is not found. The Lock is always nil for now.
func (Analyzer) HasDepMetadata ¶
HasDepMetadata determines if a dep manifest exists at the specified path.
func (Analyzer) Info ¶
func (a Analyzer) Info() gps.ProjectAnalyzerInfo
Info returns Analyzer's name and version info.
type Ctx ¶
type Ctx struct {
WorkingDir string // Where to execute.
GOPATH string // Selected Go path, containing WorkingDir.
GOPATHs []string // Other Go paths.
ExplicitRoot string // An explicitly-set path to use as the project root.
Out, Err *log.Logger // Required loggers.
Verbose bool // Enables more verbose logging.
DisableLocking bool // When set, no lock file will be created to protect against simultaneous dep processes.
Cachedir string // Cache directory loaded from environment.
CacheAge time.Duration // Maximum valid age of cached source data. <=0: Don't cache.
}
Ctx defines the supporting context of dep.
A properly initialized Ctx has a GOPATH containing the project root and non-nil Loggers.
ctx := &dep.Ctx{
WorkingDir: GOPATH + "/src/project/root",
GOPATH: GOPATH,
Out: log.New(os.Stdout, "", 0),
Err: log.New(os.Stderr, "", 0),
}
Ctx.DetectProjectGOPATH() helps with setting the containing GOPATH.
ctx.GOPATH, err := Ctx.DetectProjectGOPATH(project)
if err != nil {
// Could not determine which GOPATH to use for the project.
}
func (*Ctx) AbsForImport ¶
AbsForImport returns the absolute path for the project root including the $GOPATH. This will not work with stdlib packages and the package directory needs to exist.
func (*Ctx) DetectProjectGOPATH ¶
DetectProjectGOPATH attempt to find the GOPATH containing the project.
If p.AbsRoot is not a symlink and is within a GOPATH, the GOPATH containing p.AbsRoot is returned. If p.AbsRoot is a symlink and is not within any known GOPATH, the GOPATH containing p.ResolvedAbsRoot is returned.
p.AbsRoot is assumed to be a symlink if it is not the same as p.ResolvedAbsRoot.
DetectProjectGOPATH will return an error in the following cases:
If p.AbsRoot is not a symlink and is not within any known GOPATH. If neither p.AbsRoot nor p.ResolvedAbsRoot are within a known GOPATH. If both p.AbsRoot and p.ResolvedAbsRoot are within the same GOPATH. If p.AbsRoot and p.ResolvedAbsRoot are each within a different GOPATH.
func (*Ctx) ImportForAbs ¶
ImportForAbs returns the import path for an absolute project path by trimming the `$GOPATH/src/` prefix. Returns an error for paths equal to, or without this prefix.
func (*Ctx) LoadProject ¶
LoadProject starts from the current working directory and searches up the directory tree for a project root. The search stops when a file with the name ManifestName (Gopkg.toml, by default) is located.
The Project contains the parsed manifest as well as a parsed lock file, if present. The import path is calculated as the remaining path segment below Ctx.GOPATH/src.
func (*Ctx) SetPaths ¶
SetPaths sets the WorkingDir and GOPATHs fields. If GOPATHs is empty, then the GOPATH environment variable (or the default GOPATH) is used instead.
func (*Ctx) SourceManager ¶
SourceManager produces an instance of gps's built-in SourceManager initialized to log to the receiver's logger.
func (*Ctx) ValidateParams ¶
func (c *Ctx) ValidateParams(sm gps.SourceManager, params gps.SolveParameters) error
ValidateParams ensure that solving can be completed with the specified params.
type DeltaWriter ¶
type DeltaWriter struct {
// contains filtered or unexported fields
}
DeltaWriter manages batched writes to populate vendor/ and update Gopkg.lock. Its primary design goal is to minimize writes by only writing things that have changed.
func (*DeltaWriter) PrintPreparedActions ¶
func (dw *DeltaWriter) PrintPreparedActions(output *log.Logger, verbose bool) error
PrintPreparedActions indicates what changes the DeltaWriter plans to make.
func (*DeltaWriter) Write ¶
func (dw *DeltaWriter) Write(path string, sm gps.SourceManager, examples bool, logger *log.Logger) error
Write executes the planned changes.
This writes recreated projects to a new directory, then moves in existing, unchanged projects from the original vendor directory. If any failures occur, reasonable attempts are made to roll back the changes.
