Documentation ¶
Overview ¶
Package pack provides low level types, parsing, and semantic versioning tools to facilitate the reading, writing, and comparison of package metadata.
Index ¶
- Constants
- func DirExists(dir string) (bool, error)
- func EnsureDirectory(dir string) (bool, error)
- func FileExists(file string) (bool, error)
- func TryUriParse(pathOrUrl string) (*url.URL, error)
- type Author
- type Bzr
- type ComparisonOp
- type Constraint
- type DVCS
- type Dependency
- type Git
- type Hg
- type Pack
- type Paths
- type Repository
- type Support
- type Version
Constants ¶
const ( GOPATH = "GOPATH" GOPACKFOLDER = "gopack" SRCFOLDER = "src" )
Variables ¶
This section is empty.
Functions ¶
func EnsureDirectory ¶
EnsureDirectory ensures a directory exists, or it creates it. Returns true if the directory had to be created.
func FileExists ¶
FileExists checks to see if a directory exists.
Types ¶
type Author ¶
type Author struct { Name string `yaml:",omitempty"` Emails []string `yaml:",omitempty"` Homepage string `yaml:",omitempty"` }
Author is metadata about an author.
type Bzr ¶
type Bzr struct {
// contains filtered or unexported fields
}
Bzr uses the bazaar toolset to implement the dvcs interface.
func (*Bzr) CurrentTag ¶
CurrentTag retrieves the current tag of the repository, or empty string if no tag exists.
func (*Bzr) SetRepoPath ¶
func (d *Bzr) SetRepoPath(path string)
SetRepoPath allows overriding of the path that was set on creation.
func (*Bzr) Status ¶
Status performs a status check on the repository to see if it's actually a bzr repository.
type ComparisonOp ¶
type ComparisonOp int
ComparisonOp represents a boolean operator.
const ( // Equal is the = operator. Equal ComparisonOp = iota + 1 // NotEqual is the != operator. NotEqual // GreaterThan is the > operator. GreaterThan // LessThan is the < operator. LessThan // GreaterEqual is the >= operator. GreaterEqual // LessEqual is the <= operator. LessEqual // ApproxGreater is the ~ operator. // This operator means "greater than or equal to so long as the major // version is not incremented". ApproxGreater )
Defines the comparison operator types.
func ParseOp ¶
func ParseOp(str string) (op ComparisonOp, err error)
ParseOp parses an operation string into a comparison operator type.
func (ComparisonOp) String ¶
func (op ComparisonOp) String() (str string)
String turns a comparison operator back into a string.
type Constraint ¶
type Constraint struct { Operator ComparisonOp Version *Version }
Constraint is a constraint on a dependency.
type DVCS ¶
type DVCS interface { // Status runs a status command to see if there's actually a usable dvcs // at this location. Status() error // Close creates a command used to clone with this engine. Clone(url string) error // Update creates a command to update the repository from a source. Update() error // Checkout creates a command to change the working copy to a specified // version. Checkout(version string) error // Tags creates a command to retrieve the list of tags. Tags() ([]string, error) // CurrentTag retrieves the current tag if there is one. CurrentTag() (string, error) // SetRepoPath allows overriding of the path that was set on creation. SetRepoPath(path string) }
DVCS represents a distributed version control system.
type Dependency ¶
type Dependency struct { Name string Constraints []*Constraint URL string }
Dependency is a package dependency.
func ParseDependency ¶
func ParseDependency(str string) (*Dependency, error)
ParseDependency parses a string into a Dependency.
func (*Dependency) GetYAML ¶
func (v *Dependency) GetYAML() (_ string, value interface{})
GetYAML implements the goyaml Getter interface.
func (*Dependency) SetYAML ¶
func (d *Dependency) SetYAML(_ string, value interface{}) (ok bool)
SetYAML implements the goyaml Setter interface.
func (*Dependency) String ¶
func (d *Dependency) String() (str string)
String turns a Dependency into a String.
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
Git uses the git toolset to implement the dvcs interface.
func (*Git) CurrentTag ¶
CurrentTag retrieves the current tag of the repository, or empty string if no tag exists.
func (*Git) SetRepoPath ¶
func (d *Git) SetRepoPath(path string)
SetRepoPath allows overriding of the path that was set on creation.
func (*Git) Status ¶
Status performs a status check on the repository to see if it's actually a git repository.
type Hg ¶
type Hg struct {
// contains filtered or unexported fields
}
Hg uses the mercurial toolset to implement the dvcs interface.
func (*Hg) CurrentTag ¶
CurrentTag retrieves the current tag of the repository, or empty string if no tag exists.
func (*Hg) SetRepoPath ¶
func (d *Hg) SetRepoPath(path string)
SetRepoPath allows overriding of the path that was set on creation.
func (*Hg) Status ¶
Status performs a status check on the repository to see if it's actually an hg repository.
type Pack ¶
type Pack struct { // Display name for the package, ImportPath's trailing name if not provided. Name string `yaml:",omitempty"` // The import path of the package. ImportPath string `yaml:",omitempty"` // Version Version *Version `yaml:",omitempty"` // Short description of the package. Summary string `yaml:",omitempty"` // Longer description of the package. Description string `yaml:",omitempty"` // Homepage Homepage string `yaml:",omitempty"` // Repository Repository *Repository `yaml:",omitempty"` // License type ie. MIT, LGPL-3.0+, GPL-3.0+, Apache-2.0 License string `yaml:",omitempty"` // Authors Authors []*Author `yaml:",omitempty"` // Contributors Contributors []*Author `yaml:",omitempty"` // Support Support *Support `yaml:",omitempty"` // Dependencies of the package. Dependencies []*Dependency `yaml:",omitempty"` // Environments of the package. Environments map[string][]*Dependency `yaml:",omitempty"` // Subpackages are used to mark packages that should be tagged with this // same metadata. They must be subdirectories. This is useful for // having subpackages within the same vcs repository. Subpackages []string `yaml:",omitempty"` }
Pack is the metadata of a package.
func ParsePackFile ¶
ParsePackFile opens a file for reading and parses it into a Pack.
func (*Pack) WritePackFile ¶
WritePackFile opens a file for writing and writes the Pack to it.
type Paths ¶
type Paths struct { Gopath string Gopaths []string GopackPath string GopacksetPath string CombinedPath string // contains filtered or unexported fields }
Paths contains all the paths used by gopack.
func NewPaths ¶
NewPaths uses the environment to locate all the paths to be used and returns them in a paths variable.
func NewPathsFromGopath ¶
NewPathsFromGopath creates a new paths based on the gopath from the env.
func (*Paths) GopathRestore ¶
func (p *Paths) GopathRestore()
GopathRestore restores the original gopath variable.
func (*Paths) GopathSet ¶
func (p *Paths) GopathSet()
GopathAppend adds the combined path to the current gopath.
func (*Paths) PackageExists ¶
PackageExists checks a packages existence. If it exists it will return a path, the boolean indicates if it was in the GOPACKPATH.
func (*Paths) SetPackset ¶
SetPackset updates the packset and all paths that include packset.
type Repository ¶
type Repository struct { // Type can be one of: git/mercurial/bazaar Type string `yaml:",omitempty"` URL string `yaml:",omitempty"` }
Repository is a version control repository endpoint.
type Support ¶
type Support struct { Website string `yaml:",omitempty"` Email string `yaml:",omitempty"` Forum string `yaml:",omitempty"` Wiki string `yaml:",omitempty"` Issues string `yaml:",omitempty"` }
Support contains the locations at which to find support for the package.
type Version ¶
type Version struct { // Major version of the package. Major uint // Minor version of the package. Minor uint // Patch version of the package. Patch uint // Release version of the package. Release string }
Version is a semantic version number with an optional comparison operator. For example: 2.1.0-alpha.1 2 = Major, 1 = Minor, 0 = Patch, alpha.1 = Release For a more thorough explanation see: http://semver.org/
func ParseVersion ¶
ParseVersion parses a string into a version.
func (*Version) Satisfies ¶
func (b *Version) Satisfies(op ComparisonOp, c *Version) (ok bool)
Satisfies checks that the base version (lhs) satisfies the condition version (rhs). Example: 2.0.0 is the base version, and <=2.1.3 is the condition version will return true. Comparison is according to http://semver.org/