https://github.com/donutloop/command-pipeline
https://github.com/donutloop/command-pipeline
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/donutloop/command-pipeline
- Owner: donutloop
- License: mit
- Archived: true
- Created: 2016-10-15T11:21:20.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-12T19:47:58.000Z (over 9 years ago)
- Last Synced: 2024-06-20T15:57:36.825Z (almost 2 years ago)
- Language: Go
- Size: 6.84 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/donutloop/command-pipeline)
# Command pipeline
CommandPipeline is a lightweight high performance pipeline (using "concurrency" to execute the commands) for Go.
## Usage
This is just a quick introduction
Let's start with a trivial Hello World example:
```go
package main
import (
"github.com/donutloop/command-pipeline"
"bytes"
)
func main() {
buildCommand := func(letter string) func(input *bytes.Buffer) (*bytes.Buffer, error) {
return func(input *bytes.Buffer) (*bytes.Buffer, error) {
input.WriteString(letter)
return input, nil
}
}
firstInput := bytes.NewBufferString("H")
pipeline := command_pipeline.New(
firstInput,
buildCommand("E"),
buildCommand("L"),
buildCommand("L"),
buildCommand("O"),
buildCommand(" "),
buildCommand("W"),
buildCommand("O"),
buildCommand("R"),
buildCommand("L"),
buildCommand("D"),
)
data, _ := pipeline.Execute()
print(data.String()) //Output: HELLO WORLD
}
```