You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
281 B
Go
19 lines
281 B
Go
6 years ago
|
package log
|
||
7 years ago
|
|
||
|
import (
|
||
7 years ago
|
"io"
|
||
|
"os"
|
||
|
|
||
7 years ago
|
"golang.org/x/crypto/ssh/terminal"
|
||
|
)
|
||
|
|
||
7 years ago
|
// IsTerminal returns whether is a valid tty for io.Writer
|
||
7 years ago
|
func IsTerminal(w io.Writer) bool {
|
||
|
switch v := w.(type) {
|
||
|
case *os.File:
|
||
|
return terminal.IsTerminal(int(v.Fd()))
|
||
|
default:
|
||
|
return false
|
||
|
}
|
||
|
}
|