Added more tests
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
package tty
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
// IsTerminal returns true if the file descriptor is a terminal.
|
||||
func IsTerminal(fd uintptr) bool {
|
||||
return false
|
||||
_, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
|
||||
return err == nil
|
||||
}
|
||||
|
12
tty/Terminal_test.go
Normal file
12
tty/Terminal_test.go
Normal file
@ -0,0 +1,12 @@
|
||||
package tty_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"git.akyoto.dev/go/color/tty"
|
||||
)
|
||||
|
||||
func TestIsTerminal(t *testing.T) {
|
||||
tty.IsTerminal(os.Stdout.Fd())
|
||||
}
|
Reference in New Issue
Block a user