用于 Go 的 PTY 接口
Pty 是一个用于使用 Unix 假终端的 Go 包。
go get github.com/creack/pty请注意,这些示例仅用于演示目的,展示如何使用库。它们不适合在任何生产环境中使用。
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)
}…暂无开放 Issues,或尚未同步最近议题。