deps

package module
v0.0.0-...-f0ef26e Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2013 License: BSD-2-Clause Imports: 7 Imported by: 0

README

go-deps

xrefs funcs top func library users status

Package deps analyzes and recursively installs Go package dependencies. It is library functionality similar to go get.

Docs: go-deps on Sourcegraph

Installation

go get github.com/sourcegraph/go-deps

Example Usage

import (
    "github.com/sourcegraph/go-deps"
)

pkg, _ := deps.Read(test.importPath)
for _, p := range pkg.DepsNotFound {
    p.Download()
}

Authors

Documentation

Overview

Package deps analyzes and recursively installs Go package dependencies. It is library functionality similar to `go get`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(importPath string) error

Calls Download with the go/build.Default build context.

func GoGet

func GoGet(importPath string, mode GetMode) error

Calls GoGet with the go/build.Default build context.

Types

type Context

type Context struct {
	build.Context
	Err io.Writer
	Out io.Writer
}
var Default Context = Context{
	Context: build.Default,
	Err:     os.Stderr,
	Out:     os.Stdout,
}

func (*Context) Download

func (c *Context) Download(importPath string) error

Downloads (but does not install) the package at the given import path to the first GOPATH tree. Works like `go get -d`.

func (*Context) GoGet

func (c *Context) GoGet(importPath string, mode GetMode) error

Runs `go get` on importPath with the options specified in mode.

func (*Context) Read

func (c *Context) Read(importPath string) (pkg *Package, err error)

Reads package info for the package at importPath from `go list -json`. If importPath is "", reads the package in the current directory.

type GetMode

type GetMode int
const (
	DownloadOnly GetMode = iota
	Update
	Verbose
)

type Package

type Package struct {
	// Note: These fields are part of the go command's public API.
	// See list.go.  It is okay to add fields, but not to change or
	// remove existing ones.  Keep in sync with list.go
	Foo        bar
	Dir        string `json:",omitempty"` // directory containing package sources
	ImportPath string `json:",omitempty"` // import path of package in dir
	Name       string `json:",omitempty"` // package name
	Target     string `json:",omitempty"` // install path
	Goroot     bool   `json:",omitempty"` // is this package found in the Go root?
	Standard   bool   `json:",omitempty"` // is this package part of the standard Go library?
	Stale      bool   `json:",omitempty"` // would 'go install' do anything for this package?
	Root       string `json:",omitempty"` // Go root or Go path dir containing this package

	// Dependency information
	Imports      []string `json:",omitempty"` // import paths used by this package
	Deps         []string `json:",omitempty"` // all (recursively) imported dependencies
	DepsNotFound []string `json:",omitempty"` // all (recursive) deps that were not found

	// Error information
	Incomplete bool            `json:",omitempty"` // was there an error loading this package or dependencies?
	Error      *PackageError   `json:",omitempty"` // error loading this package (not dependencies)
	DepsErrors []*PackageError `json:",omitempty"` // errors loading dependencies
}

Relevant fields from Package struct in `go list` (cmd/go/pkg.go).

func Read

func Read(importPath string) (pkg *Package, err error)

Calls Read(importPath) with the go/build.Default build context.

type PackageError

type PackageError struct {
	ImportStack []string // shortest path from package named on command line to this one
	Pos         string   // position of error
	Err         string   // the error itself
}

A PackageError describes an error loading information about a package.

func (*PackageError) Error

func (p *PackageError) Error() string

Jump to

Keyboard shortcuts

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