execwrapper

package module
v0.0.0-...-152f18e Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2013 License: MIT Imports: 1 Imported by: 0

README

Execwrapper

A simple wrapper for Go exec that allows you to execute arbitrary strings and pipe commands. For example:

package main

import (
	"fmt"
	"github.com/hermanschaaf/execwrapper"
)

func main() {
	output, err := execwrapper.Command("echo \"why\nhello\nthere\" | grep \"hello\"").Output()
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(string(output)) // prints "hello"
}

Installation

Like many good things in life, simply install with go get:

go get github.com/hermanschaaf/execwrapper
Explanation

This is really simple, and using this package is totally overkill. The trick is to wrap normal exec commands with bash -c:

output = exec.Command("bash", "-c", cmd)
return output

It's possible that this will be extended later to deal with more platforms, in which case it might actually warrant using this package :)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command(cmd string) (output *exec.Cmd)

Types

This section is empty.

Jump to

Keyboard shortcuts

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