...

Source file src/github.com/mattn/go-colorable/colorable_others.go

Documentation: github.com/mattn/go-colorable

     1  //go:build !windows && !appengine
     2  // +build !windows,!appengine
     3  
     4  package colorable
     5  
     6  import (
     7  	"io"
     8  	"os"
     9  
    10  	_ "github.com/mattn/go-isatty"
    11  )
    12  
    13  // NewColorable returns new instance of Writer which handles escape sequence.
    14  func NewColorable(file *os.File) io.Writer {
    15  	if file == nil {
    16  		panic("nil passed instead of *os.File to NewColorable()")
    17  	}
    18  
    19  	return file
    20  }
    21  
    22  // NewColorableStdout returns new instance of Writer which handles escape sequence for stdout.
    23  func NewColorableStdout() io.Writer {
    24  	return os.Stdout
    25  }
    26  
    27  // NewColorableStderr returns new instance of Writer which handles escape sequence for stderr.
    28  func NewColorableStderr() io.Writer {
    29  	return os.Stderr
    30  }
    31  
    32  // EnableColorsStdout enable colors if possible.
    33  func EnableColorsStdout(enabled *bool) func() {
    34  	if enabled != nil {
    35  		*enabled = true
    36  	}
    37  	return func() {}
    38  }
    39  

View as plain text