util

package
v0.0.0-...-7afe134 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2014 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPath    = errors.New("program not in PATH")
	ErrTimeout = errors.New("program killed after timeout")
)
View Source
var (
	Hostname string
	// FullHostname, if false, uses the hostname upto the first ".". Run Set()
	// manually after changing.
	FullHostname bool
)

Functions

func Clean

func Clean(s string) string

Clean cleans a hostname based on the current FullHostname setting.

func Command

func Command(timeout time.Duration, name string, arg ...string) ([]byte, error)

Command executes the named program with the given arguments. If it does not exit within timeout, it is sent SIGINT (if supported by Go). After another timeout, it is killed.

func ReadCommand

func ReadCommand(line func(string) error, name string, arg ...string) error

ReadCommand runs command name with args and calls line for each line from its stdout. Command is interrupted (if supported by Go) after 10 seconds and killed after 20 seconds.

func ReadCommandTimeout

func ReadCommandTimeout(timeout time.Duration, line func(string) error, name string, arg ...string) error

ReadCommandTimeout is the same as ReadCommand with a specifiable timeout.

func Set

func Set()

Types

This section is empty.

Jump to

Keyboard shortcuts

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