diff --git a/colorable_windows.go b/colorable_windows.go index 8ff28a3..04c4229 100644 --- a/colorable_windows.go +++ b/colorable_windows.go @@ -95,6 +95,7 @@ type Writer struct { oldattr word oldpos coord rest bytes.Buffer + mutex sync.Mutex } // NewColorable returns new instance of Writer which handles escape sequence from File. @@ -432,14 +433,10 @@ func atoiWithDefault(s string, def int) (int, error) { return strconv.Atoi(s) } -var ( - writeMutex sync.Mutex -) - // Write writes data on console func (w *Writer) Write(data []byte) (n int, err error) { - writeMutex.Lock() - defer writeMutex.Unlock() + w.mutex.Lock() + defer w.mutex.Unlock() var csbi consoleScreenBufferInfo procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))