Thanks to visit codestin.com
Credit goes to github.com

Skip to content

sherjilozair/pty

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pty

Pty is a Go package for using unix pseudo-terminals.

(Note, there is only a Linux implementation. I'd appreciate a patch for other systems!)

Install

goinstall github.com/kr/pty

Example

package main

import (
    "fmt"
    "github.com/kr/pty"
    "io"
    "os"
)


func main() {
    c, err := pty.Run(
        "/bin/grep",
        []string{"grep", "--color=auto", "bar"},
        nil,
        "",
    )
    if err != nil {
        panic(err)
    }

    go func() {
        fmt.Fprintln(c.Stdin, "foo")
        fmt.Fprintln(c.Stdin, "bar")
        fmt.Fprintln(c.Stdin, "baz")
        c.Stdin.Close()
    }()
    io.Copy(os.Stdout, c.Stdout)
    c.Wait(0)
}

About

PTY interface for Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%