Documentation ¶
Overview ¶
Package byteexec provides a very basic facility for running executables supplied as byte arrays, which is handy when used with github.com/jteeuwen/go-bindata.
byteexec works by storing the provided command in a file.
Example Usage:
programBytes := // read bytes from somewhere be, err := byteexec.New(programBytes) if err != nil { log.Fatalf("Uh oh: %s", err) } cmd := be.Command("arg1", "arg2") // cmd is an os/exec.Cmd err = cmd.Run()
Note - byteexec.New is somewhat expensive, and Exec is safe for concurrent use, so it's advisable to create only one Exec for each executable.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
Types ¶
type Exec ¶
type Exec struct {
Filename string
}
Exec is a handle to an executable that can be used to create an exec.Cmd using the Command method. Exec is safe for concurrent use.
func New ¶
New creates a new Exec using the program stored in the provided data, at the provided filename (relative or absolute path allowed). If the path given is a relative path, the executable will be placed in one of the following locations:
On Windows - %APPDATA%/byteexec On OSX - ~/Library/Application Support/byteexec All Others - ~/.byteexec
Creating a new Exec can be somewhat expensive, so it's best to create only one Exec per executable and reuse that.
WARNING - if a file already exists at this location and its contents differ from data, Exec will attempt to overwrite it.