The go language is a way to pipe together two command line processes

  • 2020-05-30 20:20:04
  • OfStack

The example in this article shows how the go language pipes together two command-line processes. Share with you for your reference. The specific implementation method is as follows:

package main
import (
  "os"
  "os/exec"
  "fmt"
  "flag"
  "strings"
)
func main() {
generator := exec.Command("cmd1")
consumer := exec.Command("cmd2")
pipe, err := consumer.StdinPipe()
generator.Stdout = pipe
}

I hope this article has been helpful to your programming of Go language.


Related articles: