Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
segrey opened this issue Apr 27, 2020 · 2 comments
Closed

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

segrey opened this issue Apr 27, 2020 · 2 comments

Comments

@segrey
Copy link
Contributor

segrey commented Apr 27, 2020

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

segrey added a commit to segrey/go-colorable that referenced this issue Apr 27, 2020
segrey added a commit to segrey/go-colorable that referenced this issue Jun 25, 2020
@mattn mattn closed this as completed in b6d341e Jun 26, 2020
mattn added a commit that referenced this issue Jun 26, 2020
synchronize access to Console (fixes #48)
@kolkov
Copy link

kolkov commented Jun 26, 2020

Thanks!

@mattn
Copy link
Owner

mattn commented Jun 26, 2020

Thank you too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants