Golang os.Pipe() function examples

package os

Golang os.Pipe() function usage examples

Example 1:

 pr, pw, err := os.Pipe()
 if err != nil {
 return
 }

Example 2:

 stdout := os.Stdout
 r, w, err := os.Pipe()

 if err != nil {
 fmt.Fprintln(os.Stderr, err)
 os.Exit(1)
 }
 os.Stdout = w

See also : https://www.socketloop.com/tutorials/golang-pipe-output-from-one-os-exec-shell-command-to-another-command

Reference :

http://golang.org/pkg/os/#Pipe

Advertisement