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
- Host: GitHub
- URL: https://github.com/rikonor/go-cmdio
- Owner: rikonor
- License: mit
- Created: 2018-02-08T02:06:54.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-22T21:06:37.000Z (over 7 years ago)
- Last Synced: 2025-02-26T21:44:49.502Z (7 months ago)
- Topics: exec, go, stdin, stdio-wrapper, stdout
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cmdio
Run an executable and provide it input/output files via io.Reader/io.Writer.
## Usage
```go
package mainimport (
"log"
"os"
"os/exec"
"strings"cmdio "github.com/rikonor/go-cmdio"
)func main() {
r := strings.NewReader("Hello!")
w := os.StdoutexecPath := "./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