execer

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

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

Go to latest
Published: Mar 30, 2017 License: GPL-3.0 Imports: 5 Imported by: 0

README

Build Status GoDoc

Description

This is a go library to start system operations asynchronous.

Installation

This library is go-gettable. To install it simply run:

go get github.com/shaardie/execer

Documentation

The documentation can be found under http://godoc.org/github.com/shaardie/execer

Author

Sven Haardiek sven@haardiek.de

Documentation

Overview

Package execer provides an easy way to start system command in the background and monitor them.

Example
// Create the execer
cmd := []string{"echo", "Hello World!"}
execer, err := Init(cmd)
if err != nil {
	fmt.Println(err)
	return
}

// Start the command in the background
err = execer.Start()
if err != nil {
	fmt.Println(err)
	return
}

// Get status of the command
status := execer.Status()
if status.Error != nil {
	fmt.Println(status.Error)
	return
}
fmt.Println(status.Stdout)
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Execer

type Execer struct {
	// contains filtered or unexported fields
}

Execer represent the Command to run.

func Init

func Init(cmd []string) (Execer, error)

Create a new Execer.

len(cmd) == 0

is not allowed.

func (*Execer) Start

func (e *Execer) Start() (err error)

Start the command. Returns an error if the command is not successfully started.

func (Execer) Status

func (e Execer) Status() Status

Get the current status of the command run by `Execer`.

type Status

type Status struct {
	Error    error
	Finished bool
	Started  bool
	Stdout   string
	Stderr   string
}

Status represent the (temporarily) status of a Execer.

Error stores the (last) error. Finished indicates if the command still running. Started indicates if the command is already started. Stdout contains the commands stdout until the time the Status was created. Stderr contains the commands stderr until the time the Status was created.

Jump to

Keyboard shortcuts

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