Categorygithub.com/noxer/piper
repositorypackage
0.0.1
Repository: https://github.com/noxer/piper.git
Documentation: pkg.go.dev

# README

piper

Chain external commands in Go

docs

godoc

description

This package enables you to chain *exec.Cmds and to pipe the output from one process into another without having to manually set up the chain.

usage

This example executes the command ls -al, pipes the output to grep main and prints the result. It is the equivalent of running ls -al | grep main in your console.

package main

import (
	"fmt"

	"github.com/noxer/piper"
)

func main() {

	p := piper.Command("ls", "-al").Command("grep", "main")
	o, _ := p.CombinedOutput() // You should check the error!
	fmt.Println(string(o))

}

The *piper.Chain exposes almost the same API as a single *exec.Cmd so you can use it as a drop-in replacement most of the time.