github.com/apcera/util@v0.0.0-20180322191801-7a50bc84ee48/str/drive_terminal.go (about) 1 // Copyright 2012 Apcera Inc. All rights reserved. 2 3 // +build ignore 4 5 package main 6 7 import ( 8 "fmt" 9 target "github.com/apcera/util/str" 10 "os" 11 ) 12 13 func main() { 14 for _, label := range []string{ 15 "stdin", "stdout", "stderr", 16 } { 17 var fh *os.File 18 19 switch label { 20 case "stdin": 21 fh = os.Stdin 22 case "stdout": 23 fh = os.Stdout 24 case "stderr": 25 fh = os.Stderr 26 default: 27 panic("unknown label") 28 } 29 30 if target.IsTerminal(fh) { 31 fmt.Printf("%s is a terminal :)\n", label) 32 } else { 33 fmt.Printf("%s is not a terminal :(\n", label) 34 } 35 } 36 }