go-isatty - isatty for golang.

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

Owner
mattn
Long-time Golang user&contributor, Google Dev Expert for Go, and author of many Go tools, Vim plugin author. Windows hacker C#/Java/C/C++
mattn
Comments
  • Termux Android cannot find

    Termux Android cannot find "golang.org/x/sys/unix"

    On Termux Android, the lib depends to go-issaty is failing. It cannot find golang.org/x/sys/unix. I might relate to https://github.com/mattn/go-isatty/pull/28?

  • Enable go modules

    Enable go modules

    Go modules are becoming a de-facto standard in the Go community and adding go.mod files with metadata helps projects which may consume this repository as a dependency in deciding how to pin transitive dependencies and how to resolve conflicts.

    This is a result of the following commands:

    go mod init
    go get ./...
    go mod tidy
    

    in a clean Go 1.11.5 environment.

  • Interactive mode or not

    Interactive mode or not

    This is a feature request. Is it possible to determine if the go code is running in interactive mode or not? So that we can decide if we need to use the options / flag or interactive with end user for options.

  • Update go.sum after golang.org/x/sys update

    Update go.sum after golang.org/x/sys update

    PR #66 updated the golang.org/x/sys dependency in go.mod but didn't update go.sum. This leads to the following error on running go.test.sh:

    go: golang.org/x/[email protected]: missing go.sum entry; to add it:
    	go mod download golang.org/x/sys
    go: golang.org/x/[email protected]: missing go.sum entry; to add it:
    	go mod download golang.org/x/sys
    

    Fix this by running go mod download golang.org/x/sys && go mod tidy to update and clean up go.sum.

  • Terminal is not detected when redirecting the output from the shell

    Terminal is not detected when redirecting the output from the shell

    When executing a golang app while redirecting the output from the shell (./app > /tmp/my.log), IsTerminal() returns false even though the app is run from a terminal. Is there any reason for that?

  • IntelliJ console

    IntelliJ console

    Although the windows IsTerminal correctly detected when it is in a Windows terminal, it doesn't detect if it is in an IntelliJ terminal. Would this be possible to add? I honestly have no idea :(

    Thanks!

  • undefined: unix.IoctlGetTermios

    undefined: unix.IoctlGetTermios

    I'm trying to build a project that uses "golang:1.13.10-alpine" docker image inside of Amazon-kubernetes enviroment, but there is an error:

    vendor/github.com/mattn/go-isatty/isatty_tcgets.go:10:12: undefined: unix.IoctlGetTermios

    Any thoughts?

  • Update x/sys to support Risc-V

    Update x/sys to support Risc-V

    Updating projects using libraries that were recently updated to support Risc-V architecture.

    Go upstream work is tracked on: golang/go#27532

    Risc-V software support tracker on https://github.com/carlosedp/riscv-bringup

    Signed-off-by: CarlosEDP [email protected]

  • Missing method

    Missing method

    After you have added separate source for android builds, gin is failing because cannot find IsCygwinTerminal for android build.

    ../../gin-gonic/gin/logger.go:201:67: undefined: isatty.IsCygwinTerminal
    
  • use golang.org/x/sys/unix for IsTerminal on Linux

    use golang.org/x/sys/unix for IsTerminal on Linux

    Use the unix.IoctlGetTermios to implement IsTerminal on Linux. This allows to drop the special case for ppc64x and makes go-isatty support all GOARCHes that golang.org/x/sys/unix supports for Linux. Also this no longer requires to use ithe frozen syscall package.

  • please tag and version this project

    please tag and version this project

    Hello,

    Can you please tag and version this project?

    I am the Debian Maintainer for go-isatty and versioning would help Debian keep up with development.

  • Compatibility with newer golang.org/x/sys/unix

    Compatibility with newer golang.org/x/sys/unix

    When using this package (as a dependency of getsentry 0.15) with golang.org/x/sys/unix a golangci-lint returns following error

    [/go/pkg/mod/github.com/mattn/[email protected]/isatty_tcgets.go:7:8: could not import golang.org/x/sys/unix (/go/pkg/mod/golang.org/x/[email protected]/unix/syscall.go:83:23: Slice not declared by package unsafe)
    

    Go 1.17

  • Check that TCGETS is indeed the way to go

    Check that TCGETS is indeed the way to go

    Please check if TCGETS is appropriate here: https://github.com/mattn/go-isatty/blob/13e91bf4058fb93d5629deb7b2e3763ec8f4fdf8/isatty_tcgets.go#L11 See https://git.musl-libc.org/cgit/musl/patch/?id=2de85a985654d2c944931267645d9a0686242dfe for details.

  • Adjust build tags to allow building on tinygo; for #73.

    Adjust build tags to allow building on tinygo; for #73.

    Passes "tinygo test" on macos and linux. Passes cross test to windows from macos, i.e. "GOOS=windows tinygo test -c; wine64 go-isatty.test".

    Had to adjust the build tags on isatty_others.go to avoid multiple definition link failure on

    $ GOOS=windows tinygo test
    
  • Incompatible with tinygo?

    Incompatible with tinygo?

    Evidently zerolog 0.27 added colorization on windows by pulling in mattn/go-colorable, which in turn pulls in go-isatty. Great! Except that now zerolog can't be used with tinygo (on macos, at least, and possibly other operating systems).

    At least part of the problem can be traced to go-isatty:

    $ tinygo test
    # golang.org/x/sys/unix
    ../../go/pkg/mod/golang.org/x/[email protected]/unix/syscall_unix.go:466:17: Exec not declared by package syscall
    FAIL
    
  • IsCygwinTerminal doesn't work on Cygwin

    IsCygwinTerminal doesn't work on Cygwin

    👋🏻

    I have the following example, which when run on a Windows 10 VM with Cygwin configured it doesn't actually report anything other than "Is Terminal", when I would expect both that and "Is Cygwin/MSYS2 Terminal" to be displayed.

    package main
    
    import (
    	"fmt"
    	"os"
    
    	"github.com/mattn/go-isatty"
    )
    
    func main() {
    	if isatty.IsTerminal(os.Stdout.Fd()) {
    		fmt.Println("Is Terminal")
    	}
    	if isatty.IsCygwinTerminal(os.Stdout.Fd()) {
    		fmt.Println("Is Cygwin/MSYS2 Terminal")
    	}
    }
    

    Let me know if you need any more information.

    Thanks!

A really basic thread-safe progress bar for Golang applications
A really basic thread-safe progress bar for Golang applications

progressbar A very simple thread-safe progress bar which should work on every OS without problems. I needed a progressbar for croc and everything I tr

Jan 2, 2023
A tiny library for super simple Golang tables

Tabby A tiny library for super simple Golang tables Get Tabby go get github.com/cheynewallace/tabby Import Tabby import "github.com/cheynewallace/tabb

Nov 23, 2022
Golang terminal dashboard
Golang terminal dashboard

termui termui is a cross-platform and fully-customizable terminal dashboard and widget library built on top of termbox-go. It is inspired by blessed-c

Dec 27, 2022
go-isatty - TTY 环境判断

go-isatty isatty for golang Usage package main import ( "fmt" "github.com/mattn/go-isatty" "os" ) func main() { if isatty.IsTerminal(os.Stdout.F

Jan 7, 2023
[Crawler/Scraper for Golang]🕷A lightweight distributed friendly Golang crawler framework.一个轻量的分布式友好的 Golang 爬虫框架。

Goribot 一个分布式友好的轻量的 Golang 爬虫框架。 完整文档 | Document !! Warning !! Goribot 已经被迁移到 Gospider|github.com/zhshch2002/gospider。修复了一些调度问题并分离了网络请求部分到另一个仓库。此仓库会继续

Oct 29, 2022
Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.
Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.

#1 Golang live reload and task runner Content - ⭐️ Top Features - ???? Get started - ?? Config sample - ?? Commands List - ?? Support and Suggestions

Jan 6, 2023
golang feature toggle library - a library to help make golang feature toggling clean and easy

toggle supports env_variable backed toggling. It can also be updated via a pubsub interface (tested w/ redis) 2 engines for toggle backing are include

Mar 29, 2022
Hprose 1.0 for Golang (Deprecated). Hprose 2.0 for Golang is here:

Hprose for Golang Introduction Installation Usage Http Server Http Client Synchronous Invoking Synchronous Exception Handling Asynchronous Invoking As

Dec 15, 2022
graylog-golang is a full implementation for sending messages in GELF (Graylog Extended Log Format) from Go (Golang) to Graylog

graylog-golang is a full implementation for sending messages in GELF (Graylog Extended Log Format) from Go (Golang) to Graylog

Dec 5, 2022
Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.
Realize is the #1 Golang Task Runner which enhance your workflow by automating the most common tasks and using the best performing Golang live reloading.

#1 Golang live reload and task runner Content - ⭐️ Top Features - ???? Get started - ?? Config sample - ?? Commands List - ?? Support and Suggestions

Dec 31, 2022
Golang Skeleton With Fully Managed Versions For Kick Start GoLang Project Development
Golang Skeleton With Fully Managed Versions For Kick Start GoLang Project Development

Golang Skeleton With Fully Managed Versions For Kick Start GoLang Project Development There is no doubt that Golang’s good documentation and intellige

Dec 31, 2022
Goridge is high performance PHP-to-Golang codec library which works over native PHP sockets and Golang net/rpc package.
Goridge is high performance PHP-to-Golang codec library which works over native PHP sockets and Golang net/rpc package.

Goridge is high performance PHP-to-Golang codec library which works over native PHP sockets and Golang net/rpc package. The library allows you to call Go service methods from PHP with a minimal footprint, structures and []byte support.

Dec 28, 2022
Golang CS:GO external base. Development currently halted due to compiler/runtime Golang bugs.

gogo Golang CS:GO External cheat/base. Also, my first Golang project. Wait! Development momentarily halted due to compiler/runtime bugs. Disclaimer Th

Jun 25, 2022
golang 在线预览word,excel,pdf,MarkDown(Online Preview Word,Excel,PPT,PDF,Image by Golang)
golang 在线预览word,excel,pdf,MarkDown(Online Preview Word,Excel,PPT,PDF,Image by Golang)

Go View File 在线体验地址 http://39.97.98.75:8082/view/upload (不会经常更新,保留最基本的预览功能。服务器配置较低,如果出现链接超时请等待几秒刷新重试,或者换Chrome) 目前已经完成 docker部署 (不用为运行环境烦恼) Wor

Dec 26, 2022
memresolver is an in-memory golang resolver that allows to override current golang Lookup func literals

mem-resolver memresolver is an in-memory golang resolver that allows to override current golang Lookup func literals How to use it Create your custom

Jun 23, 2022
Using the Golang search the Marvel Characters. This project is a web based golang application that shows the information of superheroes using Marvel api.
Using the Golang search the Marvel Characters. This project is a web based golang application that shows the information of superheroes using Marvel api.

marvel-universe-web using the Golang search the Marvel Universe Characters About The Project This project is a web based golang application that shows

Oct 10, 2021
A Golang REST API to handle users and posts for a simple instagram backend. Uses MongoDB as the database. Tested using golang-testing and Postman.
A Golang REST API to handle users and posts for a simple instagram backend. Uses MongoDB as the database. Tested using golang-testing and Postman.

A Golang REST API to handle users and posts for a simple instagram backend. Uses MongoDB as the database. Tested using golang-testing and Postman.

Oct 10, 2021
packM 🧬 is fivem resource compiler for golang with the power of golang+typescript+webpack

packM ?? packM ?? is fivem resource compiler for golang ,typescript with the power of golang+typescript compiler+webpack

Jun 28, 2022
This is my first golang project. The main reason for its existence is the need for practice. I will be studying golang while writing this project

My first GoLang project Project Aim The goal of this project is to develop the most simple golang bot to learn how to work with this programming langu

Jan 7, 2022
Go (Golang) API REST with Gin FrameworkGo (Golang) API REST with Gin Framework

go-rest-api-aml-service Go (Golang) API REST with Gin Framework 1. Project Description Build REST APIs to support AML service with the support of exte

Nov 21, 2021