subprocess

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2018 License: MIT Imports: 3 Imported by: 0

README

pygz/subprocess

GitHub release Software License GoDoc Build Status Build status

A Go library that returns output/error pipes & exit status codes from new spawned processes

Documentation

Overview

Package subprocess provides support for standard output/error pipe data & exit status codes with new spawned system processes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

type Response struct {
	StdOut   string
	StdErr   string
	ExitCode int
}

Response is a struct that is returned from the public functions in the subprocess package. It contains the following fields:

Response.StdOut - (string) standard output stream cast to a string
Response.StdErr - (string) standard error stream cast to a string
Response.ExitCode - (int) executable exit status code as an integer

func Run

func Run(executable string, args ...string) Response

Run is a public function that executes a system command and returns the standard output stream, standard error stream, and exit status code data in a returned subprocess.Response struct. Run takes the following parameters:

executable (string) - the system executable for the command call
args (...string) - comma delimited list of arguments to executable

Example:

func main() {
    response := Run("go", "--help")
    fmt.Printf("%s\n", response.StdOut)
    fmt.Printf("%s\n", response.StdErr)
    fmt.Printf("%d\n", response.ExitCode)
}

Jump to

Keyboard shortcuts

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