Skip to content

Windows colored output is mixed up when running in cmd.exe #48

@segrey

Description

@segrey

Windows 10 (version 2004)
go version go1.14.2 windows/amd64

Steps to reproduce:

  1. Create "mixed-output.go"
package main

import (
    "fmt"
    "github.com/mattn/go-colorable"
    "sync"
)

func main() {
    stdout := colorable.NewColorableStdout()
    wg := &sync.WaitGroup{}
    for i := 0; i < 3; i++ {
       wg.Add(1)
       go func() {
           _, _ = fmt.Fprintln(stdout, "\u001b[32mHello\u001b[0m", "World")
           wg.Done()
       }()
    }
    wg.Wait()
}
  1. Open Command Prompt (cmd.exe) and cd to file's parent folder.
  2. go build mixed-output.go
  3. Run mixed-output.exe, the output is mixed.

Mixed output:
image

Works fine in Git bash (MinGW):
image

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