ITADN
mattn/go-isatty
README.md
以下内容由 AI 翻译,如有问题请点此提交 issue 反馈

go-isatty

Godoc Reference Codecov Coverage Status Go Report Card

golang 版的 isatty

使用方式

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")
	}
}

安装

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

许可证

MIT

作者

Yasuhiro Matsumoto(又名 mattn)

致谢