bin: github.com/rjeczalik/bin Index | Files | Directories

package bin

import "github.com/rjeczalik/bin"

Index

Package Files

bin.go bin_posix.go

func CanWrite Uses

func CanWrite(path string) bool

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

func IsBinary Uses

func IsBinary(path string) bool

IsBinary returns true if a file is binary.

func IsExecutable Uses

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 Uses

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

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

func Update Uses

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.

type Bin Uses

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 Uses

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 Uses

type BinSlice []Bin

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

func (BinSlice) Len Uses

func (b BinSlice) Len() int

func (BinSlice) Less Uses

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

func (BinSlice) Sort Uses

func (b BinSlice) Sort()

Implements sort.Interface.

func (BinSlice) Swap Uses

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

type UpdateOpts Uses

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

UpdateOpts holds the options for Update.

Directories

PathSynopsis
cmd/gobinCommand gobin Go commands by reading their import paths, go-getting their repositories and building new executables.

Package bin imports 18 packages (graph) and is imported by 1 packages. Updated 2019-03-26. Refresh now. Tools for package owners.