Clone this repo:
  1. 4237fb1 Update Go test matrix to current versions (1.24-1.26) by Yasuhiro Matsumoto · 2 weeks ago master v0.0.21
  2. 433c12b Update GitHub Actions to latest versions by Yasuhiro Matsumoto · 2 weeks ago
  3. 1cf5589 Add wasip1 and wasip2 to build constraints in isatty_others.go by Yasuhiro Matsumoto · 2 weeks ago
  4. 1237245 Update dependencies: go 1.15 -> 1.21, golang.org/x/sys v0.6.0 -> v0.28.0 by Yasuhiro Matsumoto · 2 weeks ago
  5. ac9c88d Fix typo in comment: undocomented -> undocumented by Yasuhiro Matsumoto · 2 weeks 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