Created
September 3, 2019 18:57
-
-
Save fzerorubigd/d8e139e428066e8834c8af15a1bbeacc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"github.com/mattn/go-isatty" | |
) | |
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 { | |
if isatty.IsTerminal(os.Stderr.Fd()) { | |
fmt.Fprintf(os.Stderr, "HELLO") | |
} | |
fmt.Println("Is Not Terminal") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment