Prechádzať zdrojové kódy

Add NewColorableStderr

mattn 11 rokov pred
rodič
commit
723be71070
2 zmenil súbory, kde vykonal 8 pridanie a 0 odobranie
  1. 4 0
      colorable_others.go
  2. 4 0
      colorable_windows.go

+ 4 - 0
colorable_others.go

@@ -10,3 +10,7 @@ import (
 func NewColorableStdout() io.Writer {
 	return os.Stdout
 }
+
+func NewColorableStderr() io.Writer {
+	return os.Stderr
+}

+ 4 - 0
colorable_windows.go

@@ -64,6 +64,10 @@ func NewColorableStdout() io.Writer {
 	return &Writer{out: syscall.Handle(os.Stdout.Fd())}
 }
 
+func NewColorableStderr() io.Writer {
+	return &Writer{out: syscall.Handle(os.Stderr.Fd())}
+}
+
 func (w *Writer) Write(data []byte) (n int, err error) {
 	var csbi consoleScreenBufferInfo
 	procGetConsoleScreenBufferInfo.Call(uintptr(w.out), uintptr(unsafe.Pointer(&csbi)))