Clone this repo:
  1. 4bc9b75 Lower go directive to 1.20 for Windows 7 users (#94) by Yasuhiro Matsumoto · 2 days ago master v0.0.23
  2. 4e061da add stub for haiku os (#93) by Pandora Hex · 4 days ago
  3. 9a68506 Fix isCygwinPipeName to accept Windows 7 trailing suffix (#90) by Yasuhiro Matsumoto · 3 months ago v0.0.22
  4. 4237fb1 Update Go test matrix to current versions (1.24-1.26) by Yasuhiro Matsumoto · 3 months ago v0.0.21
  5. 433c12b Update GitHub Actions to latest versions by Yasuhiro Matsumoto · 3 months ago

go-isatty

Godoc Reference Codecov Coverage Status Go Report Card

isatty for golang

Usage

package main

import (
	"fmt"
	"github.com/mattn/go-isatty"
	"os"
)

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 {
		fmt.Println("Is Not Terminal")
	}
}

Installation

$ go get github.com/mattn/go-isatty

License

MIT

Author

Yasuhiro Matsumoto (a.k.a mattn)

Thanks