Skip to content

Instantly share code, notes, and snippets.

@fzerorubigd
Created September 3, 2019 18:57
Show Gist options
  • Save fzerorubigd/d8e139e428066e8834c8af15a1bbeacc to your computer and use it in GitHub Desktop.
Save fzerorubigd/d8e139e428066e8834c8af15a1bbeacc to your computer and use it in GitHub Desktop.
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