Skip to content

Colour codes are output to non terminal #11

@hallzy

Description

@hallzy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions