gocmd package

Not in the mood to write much so I’ll keep this short…

Working with shell commands is quite a fuckin’ job in Golang.

Running a command, waiting for it to finish, checking stderr/stdout, retrieving the exit code, not that fun… Which is why I wrote this package.

Fuck it, I’m too lazy to write this. Here’s the godoc:

package gocmd

import "github.com/psyb0t/gocmd"

Easily execute shell commands

Wrapper for os/exec

Index

Package Files

cmd.go

type CMD

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

This type contains the command instructions and return values

func NewCmd

func NewCmd() *CMD

Returns a new CMD struct

func (*CMD) GetExitStatus

func (c *CMD) GetExitStatus() int

Return the exit status integer

func (*CMD) GetStderr

func (c *CMD) GetStderr() string

Return the STDERR string

func (*CMD) GetStderrBytes

func (c *CMD) GetStderrBytes() []byte

Return the STDERR bytes

func (*CMD) GetStdout

func (c *CMD) GetStdout() string

Return the STDOUT string

func (*CMD) GetStdoutBytes

func (c *CMD) GetStdoutBytes() []byte

Return the STDOUT bytes

func (*CMD) IsRunning

func (c *CMD) IsRunning() bool

Check if the command is running

func (*CMD) Kill

func (c *CMD) Kill() error

Kill the command by sending a SIGKILL

func (*CMD) Run

func (c *CMD) Run() (int, string, string, error)

Start the command and wait for it to finish running

func (*CMD) SetBinPath

func (c *CMD) SetBinPath(path string)

Set the path of the executable to be run

func (*CMD) SetParam

func (c *CMD) SetParam(param, value string)

Set one parameter for the executable

func (*CMD) SetParams

func (c *CMD) SetParams(params map[string]string)

Set multiple parameters for the executable

func (*CMD) Start

func (c *CMD) Start() error

Start the command in a goroutine

func (*CMD) Stop

func (c *CMD) Stop() error

Stop the command by sending a SIGINT

Also check it out on my github https://github.com/psyb0t/gocmd