bin

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

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

Go to latest
Published: Mar 25, 2019 License: MIT Imports: 18 Imported by: 0

README

bin GoDoc Build Status Build Status Build status

Package bin looks for Go executable system-wide ($PATH, $GOBIN, $GOPATH), lists them, reads their import paths, fetches their sources and updates them.

NOTE Go version 1.3 required.

cmd/gobin GoDoc

Installation

~ $ go get -u github.com/rjeczalik/bin/cmd/gobin

Documentation

godoc.org/github.com/rjeczalik/bin/cmd/gobin

Source example

gobin -s

Update example

gobin -u

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanWrite

func CanWrite(path string) bool

CanWrite returns true if a directory or a file specified by the path can be written.

func IsBinary

func IsBinary(path string) bool

IsBinary returns true if a file is binary.

func IsExecutable

func IsExecutable(path string) bool

IsExecutable returns true if a file under the given path looks like binary file that has executable rights. It's right most of the time.

func Source

func Source(b []Bin, gopath string) error

Source go-gets packages used to build `b` binaries into `gopath` $GOPATH.

func Update

func Update(opts UpdateOpts)

Update checks out repositories for each Go executable in b slice in a temporary directory, builds new executable and replaces it with the old one. The update is performed on multiple goroutines. Setting GOMAXPROCS may speed up this function.

Types

type Bin

type Bin struct {
	Path     string
	Package  string
	CanWrite bool
	// contains filtered or unexported fields
}

Bin represents single Go executable.

func Search(dirs []string) ([]Bin, error)

Search looks for Go executables in all the directories specified by the dirs slice. If dirs is nil or empty, executables are looked up in directories specified by the $GOPATH, $GOBIN and $PATH environment variables. The lookup is performed on multiple goroutines. Setting GOMAXPROCS may speed up this function.

func SearchSymlink(dirs []string) ([]Bin, map[string][]Bin, error)

Search looks for Go executables in all the directories specified by the dirs slice resolving any symlinks it discovers. If dirs is nil or empty, executables are looked up in directories specified by the $GOPATH, $GOBIN and $PATH environment variables. The lookup is performed on multiple goroutines. Setting GOMAXPROCS may speed up this function. TODO: The symlink part is not implemented yet, map is always nil/empty.

func (Bin) Err

func (b Bin) Err() error

Err returns any error a Bin may hold. The error may be set by PATH lookup routines or when guessing import path of the executable fails.

type BinSlice

type BinSlice []Bin

BinSlice attaches the methods of Interface to []Bin, sorting in increasing Bin.Path order.

func (BinSlice) Len

func (b BinSlice) Len() int

func (BinSlice) Less

func (b BinSlice) Less(i, j int) bool

func (BinSlice) Sort

func (b BinSlice) Sort()

Implements sort.Interface.

func (BinSlice) Swap

func (b BinSlice) Swap(i, j int)

type UpdateOpts

type UpdateOpts struct {
	Bins  []Bin
	Log   func(*Bin, time.Duration, error)
	Flags []string
}

UpdateOpts holds the options for Update.

Directories

Path Synopsis
cmd
gobin
Command gobin Go commands by reading their import paths, go-getting their repositories and building new executables.
Command gobin Go commands by reading their import paths, go-getting their repositories and building new executables.

Jump to

Keyboard shortcuts

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