shell

package module
v0.0.0-...-d276b37 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: MIT Imports: 5 Imported by: 0

README

Shell

GoDoc

Simple package for running shell scripts with Go. Pairs well with gorun.

Example

/// 2>/dev/null ; gorun "$0" "$@" ; exit $?

package main

import (
	"fmt"

	"github.com/matthewmueller/shell"
)

var sh = shell.Runf

func main() {
	hi := sh("echo %q", "hi")
	fmt.Printf(hi)
}

Install

go get -u github.com/matthewmueller/shell

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(command string) (stdout string)

Run a command in the shell. This command will exit immediately with status code 1 if it encounters any errors. The commands run in the current working directory with the environment passed in. Standard error goes directly out to the shell. Stdout is buffered returned when the command finishes.

func Runf

func Runf(command string, a ...interface{}) string

Runf a command in the shell. See Run for more details.

Types

This section is empty.

Jump to

Keyboard shortcuts

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