An open API service indexing awesome lists of open source software.

https://github.com/rikonor/go-cmdio

Run an executable and provide it input/output files via io.Reader/io.Writer
https://github.com/rikonor/go-cmdio

exec go stdin stdio-wrapper stdout

Last synced: 3 months ago
JSON representation

Run an executable and provide it input/output files via io.Reader/io.Writer

Awesome Lists containing this project

README

          

# cmdio

Run an executable and provide it input/output files via io.Reader/io.Writer.

## Usage

```go
package main

import (
"log"
"os"
"os/exec"
"strings"

cmdio "github.com/rikonor/go-cmdio"
)

func main() {
r := strings.NewReader("Hello!")
w := os.Stdout

execPath := "./text-doubler"
execArgs := []string{"INPUT", "OUTPUT"}

tmpArgs, closeFn, err := cmdio.WrapSimple(r, w, execArgs)
if err != nil {
log.Fatal(err)
}
defer closeFn()

cmd := exec.Command(execPath, tmpArgs...)
if err := cmd.Run(); err != nil {
log.Fatal(err)
}
}
```

## License

MIT