This uses ioctl syscalls or appropriate alternative, to detect if stdin/out/err are character devices or not. This caches the result, to ensure performance is ok at runtime as executing stat can approach microsecond overhead. Signed-off-by: Adrian Cole <adrian@tetrate.io>
13 lines
151 B
Go
13 lines
151 B
Go
package platform
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func Benchmark_IsTerminal(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
IsTerminal(os.Stdout.Fd())
|
|
}
|
|
}
|