commit | 4684196194d794ae77a4dcad1a1bab9aee275dd7 | [log] [tgz] |
---|---|---|
author | Tobias Klauser <tklauser@distanz.ch> | Tue Aug 28 10:08:28 2018 |
committer | Tobias Klauser <tklauser@distanz.ch> | Wed Sep 05 16:03:44 2018 |
tree | 91fbef6fb54216748926626d94308b4a4d06e366 | |
parent | 3fb116b820352b7f0c281308a4d6250c22d94e27 [diff] |
use golang.org/x/sys/unix for IsTerminal on Linux Use the unix.IoctlGetTermios to implement IsTerminal on Linux. This allows to drop the special case for ppc64x and makes go-isatty support all GOARCHes that golang.org/x/sys/unix supports for Linux. Also this no longer requires to use ithe frozen syscall package.
isatty for golang
package main
import (
"fmt"
"github.com/mattn/go-isatty"
"os"
)
func main() {
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Println("Is Terminal")
} else if isatty.IsCygwinTerminal(os.Stdout.Fd()) {
fmt.Println("Is Cygwin/MSYS2 Terminal")
} else {
fmt.Println("Is Not Terminal")
}
}
$ go get github.com/mattn/go-isatty
MIT
Yasuhiro Matsumoto (a.k.a mattn)
k-takata: base idea for IsCygwinTerminal