sjansen/mecha

View on GitHub
spikes/pty/main.go

Summary

Maintainability
A
0 mins
Test Coverage
package main

import (
    "io"
    "os"
    "os/exec"

    "github.com/creack/pty"
)

func main() {
    c := exec.Command("grep", "--color=auto", "bar")
    f, err := pty.Start(c)
    if err != nil {
        panic(err)
    }

    go func() {
        f.Write([]byte("foo\n"))
        f.Write([]byte("bar\n"))
        f.Write([]byte("baz\n"))
        f.Write([]byte{4}) // EOT
    }()
    io.Copy(os.Stdout, f)
}