godm

package module
v0.0.0-...-5dc5273 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2015 License: MIT Imports: 14 Imported by: 0

README

godm

A go1.5+ dependencies manager. Build Status GoDoc Coverage Status

More precisely, a tool to manage your project's dependencies by vendoring them at pinpointed versions.

It relies on the "GO15VENDOREXPERIMENT", so that other people (users and developers) can simply go get your project without being forced to use godm or any other tool that doesn't come with Go right out of the box.

If you wish to see how does a project using godm looks, well you got one right here :)

Vendors are there as Git submodules

Table of Contents

Table of Contents generated with DocToc

Status

Still in very early development.

Dependencies

Go 1.5+ (with GO15VENDOREXPERIMENT=1), and Git (available in your $PATH)

Installation

# If you haven't already, enable the Go 1.5 vendor experiment (personally that line is in my ~/.bashrc).
export GO15VENDOREXPERIMENT=1
# Then it's a simple go get.
go get github.com/hectorj/godm/cmd/godm

Upgrade

go get -u github.com/hectorj/godm/cmd/godm

Usage

Note : does not support Mercurial yet

help

Auto-generated help is available like this :

godm --help

(thanks to https://github.com/codegangsta/cli)

vendor

The vendor sub-command vendors imports that are not vendored yet in the current project. Outputs the import paths of vendors successfully added.

# Go to your package directory, wherever that is.
cd $GOPATH/src/myPackage
# Run it.
godm vendor
# If everything went well, you have new git submodules you can commit.
git commit -m "Vendoring done by godm"
clean

The clean sub-command removes vendors that are not imported in the current project. Outputs the import paths of vendors successfully removed.

# Go to your package directory, wherever that is.
cd $GOPATH/src/myPackage
# Run it.
godm clean
# If everything went well, you may have some Git submodules removals you can commit.
git commit -m "Vendors cleaning done by godm"
remove

The remove sub-command unvendors an import path. Takes a single import path as argument.

# Go to your package directory, wherever that is.
cd $GOPATH/src/myPackage
# Run godm
godm remove github.com/my/import/path
# If everything went well, you have a Git submodule removal you can commit.
git commit -m "Unvendoring done by godm"

Bash Autocompletion

Copy godm_bash_autocomplete.bash to /etc/bash_completion.d/ to get command autocompletion (highly recommended)

Migrating from another dependencies management tool

Godep
godep restore
GOPATH=`godep path`:$GOPATH godm save

Once you have checked the migration went well, you can eventually rm -rf ./Godeps

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateVendor = errors.New("Vendor already added to this project")
	ErrUnknownVendor   = errors.New("Vendor doesn't exist in this project")
)
View Source
var DefaultExcludesRegexp = []*regexp.Regexp{regexp.MustCompile(`/?vendor/?`)}
View Source
var ErrImportPathNotFound = errors.New("Import path not found in GOPATH nor as Go-Gettable")
View Source
var ErrNotImplemented = errors.New("Feature not implemented yet")
View Source
var ErrOrphan = errors.New("Vendor does not have a parent project")
View Source
var ErrStandardLibrary = errors.New("Import path is part of the standard library")

Functions

func CopyDir

func CopyDir(src, target string) error

func NewGitProjectFromPath

func NewGitProjectFromPath(path, rootPath string) (*localGitProject, error)

func NewlocalGitProjectFromURI

func NewlocalGitProjectFromURI(uri, reference string) *localGitProject

func RemoveSubdirsWithNoFiles

func RemoveSubdirsWithNoFiles(dirPath string) (hasAtLeastOneFile bool, err error)

Types

type LocalGitProject

type LocalGitProject interface {
	LocalProject
	// GetReference returns the HEAD reference.
	// Can be a commit hash, a branch, a tag etc.
	// Must be usable with the `git checkout` command
	GetReference() (string, error)
	// GetRemote returns the RemoteGitProject if possible
	// Returns nil if there is no remote.
	GetRemote() (RemoteGitProject, error)
}

type LocalProject

type LocalProject interface {
	Project
	// GetVendors returns all the project's vendors as a map[importPath]Vendor
	GetVendors() (vendors map[string]Vendor, err error)
	// AddVendor adds a vendor to the project
	AddVendor(importPath string, project Project) (Vendor, error)
	// RemoveVendor removes a vendor from the project by import path
	RemoveVendor(importPath string) error
	// GetImports returns all the project's imports (as a set of import paths)
	GetImports() (importPaths Set, err error)
	// GetSubpackages returns all the project's subpackages, (excluding vendors).
	GetSubpackages() (subpackages Set, err error)
	// GetBaseDir returns the path to the base directory of the project
	GetBaseDir() string
}

LocalProject represents a Project we have available on the local file system

func NewLocalProject

func NewLocalProject(path string, rootPath string) (LocalProject, error)

NewLocalProject takes a path and builds a Project object from it, determining if it is a Git/Mercurial/No VCL/etc. project

type Project

type Project interface {
	// Install downloads/copies/generates the project at specified destination on the filesystem
	Install(destination string) (LocalProject, error)
}

Project represents a Go project

func NewProjectFromImportPath

func NewProjectFromImportPath(importPath string) (Project, string, error)

type ProjectNoVCL

type ProjectNoVCL struct {
	BaseDir      string
	Recursive    bool
	Subpackages  Set
	Imports      Set
	Vendors      map[string]Vendor
	GoFiles      Set
	PathExcludes []*regexp.Regexp
	// contains filtered or unexported fields
}

ProjectNoVCL is the most baisc local project : without any Version Control System

func NewProjectNoVCL

func NewProjectNoVCL(path string) *ProjectNoVCL

func (*ProjectNoVCL) AddVendor

func (self *ProjectNoVCL) AddVendor(importPath string, project Project) (Vendor, error)

AddVendor by simply copying it

func (*ProjectNoVCL) GetBaseDir

func (self *ProjectNoVCL) GetBaseDir() string

func (*ProjectNoVCL) GetImports

func (self *ProjectNoVCL) GetImports() (importPaths Set, err error)

func (*ProjectNoVCL) GetSubpackages

func (self *ProjectNoVCL) GetSubpackages() (subpackages Set, err error)

func (*ProjectNoVCL) GetVendors

func (self *ProjectNoVCL) GetVendors() (vendors map[string]Vendor, err error)

func (*ProjectNoVCL) Install

func (self *ProjectNoVCL) Install(destination string) (LocalProject, error)

func (*ProjectNoVCL) RemoveVendor

func (self *ProjectNoVCL) RemoveVendor(importPath string) error

RemoveVendor by deleting it from the file system

type RemoteGitProject

type RemoteGitProject interface {
	Project
	// GetURI returns a fetchable URI for the repository
	GetGitURI() string
}

type Set

type Set map[string]struct{}

Set is a simple strings set implementation Warning : It is not concurrency-safe

func NewSet

func NewSet(values ...string) Set

func (*Set) Add

func (self *Set) Add(value string)

func (*Set) AddSet

func (self *Set) AddSet(set Set)

func (Set) Has

func (self Set) Has(value string) bool

func (*Set) Remove

func (self *Set) Remove(value string)

type Vendor

type Vendor interface {
	LocalProject
	// GetParent returns the project vendoring this one.
	GetParent() Project
	// SetParent saves the reference to the project vendoring this one.
	SetParent(parent Project)
	// GetBaseImportPath returns the base import path (the one containing all the eventual subpackages)
	GetImportPath() string
	// GetProject returns the vendor's project
	GetProject() LocalProject
}

Vendor represents a vendored project

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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