Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colour codes are output to non terminal #11

Open
hallzy opened this issue May 20, 2021 · 0 comments
Open

Colour codes are output to non terminal #11

hallzy opened this issue May 20, 2021 · 0 comments

Comments

@hallzy
Copy link
Owner

hallzy commented May 20, 2021

If output of program is redirected to a file for some reason, the colour codes should be suppressed.

This is how I can do the detection:

package main
 
import (
    "os"
    "fmt"
)
 
func main() {
    if fileInfo, _ := os.Stdout.Stat(); (fileInfo.Mode() & os.ModeCharDevice) != 0 {
        fmt.Println("Hello terminal")
    } else {
        fmt.Println("Who are you? You're not a terminal")
    }
}

Just have to adapt that for this code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant