Skip to content

Instantly share code, notes, and snippets.

@ssbb
Created November 24, 2015 05:05
Show Gist options
  • Save ssbb/a83b6537139d79ee6e1b to your computer and use it in GitHub Desktop.
Save ssbb/a83b6537139d79ee6e1b to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"os/exec"
)
func main() {
data := make([]byte, 1024*512)
cmd := exec.Command("wc")
stdin, err := cmd.StdinPipe()
if err != nil {
log.Fatal(err)
}
fmt.Println("Writing ot stdin...")
stdin.Write(data)
stdin.Close()
fmt.Println("Wrote to stdin")
code := cmd.Run()
fmt.Println(code)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment