gochips

package module
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2019 License: MIT Imports: 8 Imported by: 8

README

gochips

Small useful pieces of golang code

Documentation

Index

Constants

View Source
const (
	StderrRedirectNone = iota
	StderrRedirectStdout
	StderrRedirectNull
)

Stderr redirection

Variables

View Source
var Doing func(arg interface{})

Doing printlns "$obj..." to stdout

View Source
var Info func(args ...interface{})

Info printlns to stdout

View Source
var IsVerbose = false

IsVerbose enables Verbose

View Source
var Output func(funcName, s string)

Output is used by all functions

View Source
var Verbose func(subj string, args ...interface{})

Verbose If IsVerbose is true printlns VerbosePrefix + subj + ": " + ...args args are printed in %#+v format (json-like)

View Source
var VerbosePrefix = "--- "

VerbosePrefix prefixes Verbose output

View Source
var VerboseWriters func() (out io.Writer, err io.Writer)

VerboseWriters returns (os.Stdout, os.Stderr) if IsVerbose, (ioutil.Discard, os.Stderr) otherwise

Functions

func ExitIfError

func ExitIfError(err error, args ...interface{})

ExitIfError s.e.

func ExitIfFalse

func ExitIfFalse(cond bool, args ...interface{})

ExitIfFalse s.e.

func Fatal added in v1.6.0

func Fatal(args ...interface{})

Fatal exists with given parameters

func PanicIfError

func PanicIfError(err error)

PanicIfError panics if err is not null

Types

type PipedExec

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

PipedExec allows to execute commands in pipe

func (*PipedExec) Command

func (Self *PipedExec) Command(name string, args ...string) *PipedExec

Command adds a command to a pipe

func (*PipedExec) GetCmd added in v1.8.0

func (Self *PipedExec) GetCmd(idx int) *exec.Cmd

GetCmd returns cmd with given index

func (*PipedExec) Run

func (Self *PipedExec) Run(out io.Writer, err io.Writer) error

Run starts the pipe

func (*PipedExec) RunToStrings added in v1.8.0

func (Self *PipedExec) RunToStrings() (stdout string, stderr string, err error)

RunToStrings runs the pipe and saves outputs to strings

func (*PipedExec) Start added in v1.8.0

func (Self *PipedExec) Start(out io.Writer, err io.Writer) error

Start all cmds

func (*PipedExec) Wait added in v1.8.0

func (Self *PipedExec) Wait() error

Wait until all cmds finish

func (*PipedExec) WorkingDir

func (Self *PipedExec) WorkingDir(wd string) *PipedExec

WorkingDir sets working directory for the last command

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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