go.pipeline is a utility library that imitates unix pipeline. It simplifies chaining unix commands (and other stuff) in Go.

Overview

go.pipeline

go.pipeline is a utility library that imitates unix pipeline. It simplifies chaining unix commands (and other stuff) in Go.

Installation

go get -u github.com/songgao/go.pipeline

Documentation

http://godoc.org/github.com/songgao/go.pipeline

Examples

Execute a single unix command

package main

import "github.com/songgao/go.pipeline"

func main() {
	pipeline.StartPipelineWithCommand("uname", "-a").PrintAll()
}

Chain multiple unix commands

Following code is equal to ls -h -l /bin | egrep --color=always -e "\\ *[0-9.]*M\\ *", plus a counter pre-pended to each line.

package main

import (
	"fmt"
	"github.com/songgao/go.pipeline"
)

func main() {
	counter := 0

	pipeline.NewPipeline().
		ChainCommand("ls", "-h", "-l", "/bin").ChainCommand("egrep", "--color=always", "-e", `\ *[0-9.]*M\ *`).
		ChainLineProcessor(func(in string) string {
		counter++
		return fmt.Sprintf("%d:\t%s", counter, in)
	}, nil).PrintAll()
}

An equivalent shorter version is:

package main

import (
	"fmt"
	"github.com/songgao/go.pipeline"
)

func main() {
	counter := 0

	pipeline.NewPipeline().
		C("ls", "-h", "-l", "/bin").C("egrep", "--color=always", "-e", `\ *[0-9.]*M\ *`).
		L(func(in string) string {
		counter++
		return fmt.Sprintf("%d:\t%s", counter, in)
	}, nil).P()
}

Colorize go build output

Check out colorgo project: https://github.com/songgao/colorgo

TODO

  • tee, etc.
  • custom Station
  • package doc
  • more organized README.md

License

BSD 3-Clause License

You might also like...
Databases and dashboards loved each other so much that databoard was born.

databoard Work in progress tool to create API endpoints that executes queries on connected database. ⚠ The project is on early-development stage. Plan

This example implements a basic example of how to create your own modules, and how to call them from other modules

This example implements a basic example of how to create your own modules, and how to call them from other modules. In addition, an example of how to do unit tests is developed.

vtysock is a vtysh replacement that directly sends commands to the vty sockets of the daemons

vtysock vtysock is a vtysh replacement that directly sends commands to the vty sockets of the daemons. By skipping the parsing and validation checks d

Alerts on due products from Grocy through emails or other means.

grocy-alerts Grocy alerts was made in an attempt to give more visibility to expiring soon products in Grocy. Usage Fetch products from grocy api and c

other glyph sets for high-dpi 1-bit monochrome

hd1b_other other glyph sets for high-dpi 1-bit monochrome Currently included glyph sets: Hangul (Korean): U+1100..U+11FF, U+3131..U+318E, U+AC00..U+D7

Pango GINX is a GO development utility library for GIN.
Pango GINX is a GO development utility library for GIN.

Pango GINX Pango GINX is a GO development utility library for GIN. Package Description gindump a http request/response dumper middleware for gin ginfi

Go package and associated command line utility to generate random yet human-readable names and identifiers
Go package and associated command line utility to generate random yet human-readable names and identifiers

namegen | What's this? Go package and associated command line utility to generate random yet human-readable names and identifiers. Somewhat inspired b

This utility parses stackoverflow data and pushes it to Zinc/Elasticsearch

Gostack This utility parses stackoverflow data and pushes it to Zinc/Elasticsear

An open source gitlab linting utility

gitlab-lint API and collector An open source gitlab linting utility Frontend https://github.com/globocom/gitlab-lint-react How to install Install depe

Comments
  • Question sending

    Question sending "name"

    I'm trying to run "Gnuplot" with go.pipeline. To execute a surface plot I need to send the name of a file to splot. For example Splot "Filename". How I do I send quoted filename? Any suggestions would be appreciated.

    Jim

    opened by jtc25 5
  • Question sending

    Question sending "name"

    I'm trying to run "Gnuplot" with go.pipeline. To execute a surface plot I need to send the name of a file to splot. For example Splot "Filename". How I do that? Any suggestions would be appreciated.

    Jim

    opened by jtc25 0
Owner
Song Gao
Song Gao
The primary place where Optimism works on stuff related to Optimistic Ethereum

The Optimism Monorepo TL;DR This is the primary place where Optimism works on stuff related to Optimistic Ethereum. Documentation Extensive documentat

Onther Inc. Technology 4 Dec 16, 2022
Code for the Go pipeline blog post

Concurrent and Parallel Pipelines in Go This repository contains the code that goes along with a blog post about concurrent and parallel pipelines in

AMBOSS 9 Nov 11, 2022
A sample golang project to demonstrate the integration with rancher pipeline

pipeline-example-go This is a sample golang project to demonstrate the integration with rancher pipeline. Building go build -o ./bin/hello-server Runn

null 0 Oct 30, 2021
A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell.

shellwords A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell. Installation go get github.com/Wing924

Wei He 18 Sep 27, 2022
Vulture - A Unix Operating System Built Using Golang

vulture A Unix Operating System Built Using Golang Requirements: macOS: make sur

null 16 Dec 30, 2022
Ghdl - A much more convenient way to download GitHub release binaries on the command line, works on Win & Unix-like systems

ghdl Memorize ghdl as github download ghdl is a fast and simple program (and als

beet 49 Oct 12, 2022
Executor - Wrapper for exec.Command for simple using and multi commands executing

executor Examples package main import ( "fmt" "github.com/solar-jsoc/execut

null 5 Feb 12, 2022
🏃‍♂️ A new way to execute commands and manipulate command output in Go

??‍♂️ A new way to execute commands and manipulate command output in Go

Sourcegraph 20 Nov 11, 2022
Workaround for running ubuntu:21.10, fedora:35, and other glibc >= 2.34 distros on Docker <= 20.10.9

clone3-workaround: Workaround for running ubuntu:21.10, fedora:35, and other glibc >= 2.34 distros on Docker <= 20.10.9 Old container engines such as

Akihiro Suda 10 Dec 1, 2022
Marquee for bar and other things.

Marquee for bar and other things.

Gabriel 1 Oct 5, 2021