Documentation ¶
Index ¶
- Constants
- func BackupVendor(vpath, suffix string) (string, error)
- func PruneProject(p *Project, sm gps.SourceManager, logger *log.Logger) error
- type Analyzer
- type Ctx
- type Lock
- type Loggers
- type Manifest
- func (m *Manifest) DependencyConstraints() gps.ProjectConstraints
- func (m *Manifest) IgnoredPackages() map[string]bool
- func (m *Manifest) MarshalTOML() ([]byte, error)
- func (m *Manifest) Overrides() gps.ProjectConstraints
- func (m *Manifest) RequiredPackages() map[string]bool
- func (m *Manifest) TestDependencyConstraints() gps.ProjectConstraints
- type Project
- type SafeWriter
- type SolveMeta
- type SortedLockedProjects
- type VendorBehavior
Constants ¶
const LockName = "Gopkg.lock"
const ManifestName = "Gopkg.toml"
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.
func PruneProject ¶
Types ¶
type Ctx ¶
type Ctx struct { GOPATH string // Selected Go path GOPATHS []string // Other Go paths WorkingDir string *Loggers }
Ctx defines the supporting context of the tool.
func NewContext ¶
NewContext creates a struct with the project's GOPATH. It assumes that of your "GOPATH"'s we want the one we are currently in.
func (*Ctx) LoadProject ¶
LoadProject takes a path and searches up the directory tree for a project root. If an absolute path is given, the search begins in that directory. If a relative or empty path is given, the search start is computed from the current working directory. 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) SplitAbsoluteProjectRoot ¶
SplitAbsoluteProjectRoot takes an absolute path and compares it against declared GOPATH(s) to determine what portion of the input path should be treated as an import path - as a project root.
The second returned string indicates which GOPATH value was used.
func (*Ctx) VersionInWorkspace ¶
type Lock ¶
type Lock struct { SolveMeta SolveMeta P []gps.LockedProject }
func LockFromSolution ¶
LockFromSolution converts a gps.Solution to dep's representation of a lock.
Data is defensively copied wherever necessary to ensure the resulting *lock shares no memory with the original lock.
func (*Lock) MarshalTOML ¶
func (*Lock) Projects ¶
func (l *Lock) Projects() []gps.LockedProject
type Manifest ¶
type Manifest struct { Constraints gps.ProjectConstraints Ovr gps.ProjectConstraints Ignored []string Required []string }
func (*Manifest) DependencyConstraints ¶
func (m *Manifest) DependencyConstraints() gps.ProjectConstraints
func (*Manifest) IgnoredPackages ¶
func (*Manifest) MarshalTOML ¶
func (*Manifest) Overrides ¶
func (m *Manifest) Overrides() gps.ProjectConstraints
func (*Manifest) RequiredPackages ¶
func (*Manifest) TestDependencyConstraints ¶
func (m *Manifest) TestDependencyConstraints() gps.ProjectConstraints
type Project ¶
type Project struct { // AbsRoot is the absolute path to the root directory of the project. AbsRoot string // ImportRoot is the import path of the project's root directory. ImportRoot gps.ProjectRoot Manifest *Manifest Lock *Lock }
func (*Project) MakeParams ¶
func (p *Project) MakeParams() gps.SolveParameters
MakeParams is a simple helper to create a gps.SolveParameters without setting any nils incorrectly.
type SafeWriter ¶
type SafeWriter struct { Manifest *Manifest // contains filtered or unexported fields }
SafeWriter transactionalizes writes of manifest, lock, and vendor dir, both individually and in any combination, into a pseudo-atomic action with transactional rollback.
It is not impervious to errors (writing to disk is hard), but it should guard against non-arcane failure conditions.
func NewSafeWriter ¶
func NewSafeWriter(manifest *Manifest, oldLock, newLock *Lock, vendor VendorBehavior) (*SafeWriter, error)
NewSafeWriter sets up a SafeWriter to write a set of config yaml, lock and vendor tree.
- If manifest is provided, it will be written to the standard manifest file name beneath root.
- If newLock is provided, it will be written to the standard lock file name beneath root.
- If vendor is VendorAlways, or is VendorOnChanged and the locks are different, the vendor directory will be written beneath root based on newLock.
- If oldLock is provided without newLock, error.
- If vendor is VendorAlways without a newLock, error.
func (*SafeWriter) HasLock ¶
func (sw *SafeWriter) HasLock() bool
HasLock checks if a Lock is present in the SafeWriter
func (*SafeWriter) HasManifest ¶
func (sw *SafeWriter) HasManifest() bool
HasManifest checks if a Manifest is present in the SafeWriter
func (*SafeWriter) PrintPreparedActions ¶
func (sw *SafeWriter) PrintPreparedActions(output *log.Logger) error
func (*SafeWriter) Write ¶
func (sw *SafeWriter) Write(root string, sm gps.SourceManager, noExamples bool) error
Write saves some combination of config yaml, lock, and a vendor tree. root is the absolute path of root dir in which to write. sm is only required if vendor is being written.
It first writes to a temp dir, then moves them in place if and only if all the write operations succeeded. It also does its best to roll back if any moves fail. This mostly guarantees that dep cannot exit with a partial write that would leave an undefined state on disk.
type SortedLockedProjects ¶
type SortedLockedProjects []gps.LockedProject
func (SortedLockedProjects) Len ¶
func (s SortedLockedProjects) Len() int
func (SortedLockedProjects) Less ¶
func (s SortedLockedProjects) Less(i, j int) bool
func (SortedLockedProjects) Swap ¶
func (s SortedLockedProjects) Swap(i, j int)
type VendorBehavior ¶
type VendorBehavior int
VendorBehavior defines when the vendor directory should be written.
const ( // VendorOnChanged indicates that the vendor directory should be written when the lock is new or changed. VendorOnChanged VendorBehavior = iota // VendorAlways forces the vendor directory to always be written. VendorAlways // VendorNever indicates the vendor directory should never be written. VendorNever )
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
dep
Command dep is a prototype dependency management tool.
|
Command dep is a prototype dependency management tool. |
hack
|
|
licenseok
Checks if all files have the license header, a lot of this is based off https://github.com/google/addlicense.
|
Checks if all files have the license header, a lot of this is based off https://github.com/google/addlicense. |
internal
|
|