Documentation ¶
Overview ¶
Package implements shell like DSL for executing commands and making transformations. Main motivation was to write CI/CD scripts in Go instead of Makefile/bash etc.
Example ¶
packagesForTest := "" MustRun( Exec("go list ./..."), ToString(&packagesForTest), ) packagesForCover := strings.ReplaceAll(packagesForTest, "\n", ",") MustRun( Execf("go test %v -coverpkg=%v -coverprofile=./coverage.out", packagesForTest, packagesForCover), Tee("go-test.log"), )
Output:
Index ¶
- func MustRun(pipes ...Op)
- func Run(pipes ...Op) error
- func ScanLinesWithoutDrop(data []byte, atEOF bool) (advance int, token []byte, err error)
- func ScanWordsWithoutDrop(data []byte, atEOF bool) (advance int, token []byte, err error)
- type Op
- func Exec(cmd string) Op
- func ExecWithCmd(cmdString string, cmd exec.Cmd, stderrToStdin bool) Op
- func Execf(cmd string, a ...interface{}) Op
- func Filter(match string) Op
- func FromFile(path string) Op
- func Glob(path string) Op
- func Map(f func(string) []string) Op
- func Replace(what, to string) Op
- func String() Op
- func Tee(path string) Op
- func ToFile(path string) Op
- func ToString(dst *string) Op
- func Transformer(splitFunc bufio.SplitFunc, transformFunc func([]byte) []byte) Op
- func Watch(lines int) Op
- type Ops
- type TransformerAsyncPipe
- type WatchAsyncPipe
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustRun ¶
func MustRun(pipes ...Op)
The same as Run, but if one of operations fails will call log.Fatal(err) and stops execution
func Run ¶
Run a chain of operations similar to shell: $> op1 | op2 | op3 Returns errors if one of the operation fails
func ScanLinesWithoutDrop ¶
Types ¶
type Op ¶
type Op interface { Run() error SetInput(io.ReadCloser) GetReader() io.ReadCloser }
func Transformer ¶
Example ¶
var res string MustRun( Exec("echo one two three"), Replace("three", "one"), Filter("two"), ToString(&res), ) fmt.Print(res)
Output: one one
type TransformerAsyncPipe ¶
type TransformerAsyncPipe struct {
// contains filtered or unexported fields
}
func (*TransformerAsyncPipe) GetReader ¶
func (p *TransformerAsyncPipe) GetReader() io.ReadCloser
func (*TransformerAsyncPipe) Run ¶
func (p *TransformerAsyncPipe) Run() error
func (*TransformerAsyncPipe) SetInput ¶
func (p *TransformerAsyncPipe) SetInput(in io.ReadCloser)
type WatchAsyncPipe ¶
type WatchAsyncPipe struct {
// contains filtered or unexported fields
}
func (*WatchAsyncPipe) GetReader ¶
func (p *WatchAsyncPipe) GetReader() io.ReadCloser
func (*WatchAsyncPipe) Run ¶
func (p *WatchAsyncPipe) Run() error
func (*WatchAsyncPipe) SetInput ¶
func (p *WatchAsyncPipe) SetInput(in io.ReadCloser)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.