Skip to content

race condition when calling Theme.Tips concurrently #95

@unkmonster

Description

@unkmonster

System (please complete the following information):

  • OS: window [e.g. linux, macOS]
  • GO Version: 1.13 [e.g. 1.13]
  • Pkg Version: 1.1.1 [e.g. 1.1.1]

ENV info on the terminal (by command env | grep -i TERM)

// paste env info.
Windows 11 Terminal

Describe the bug

Multiple goroutines calling Theme.Tips concurrently may cause mixed output

Since both t.Print and Printf perform I/O operations, concurrent writes to the output may lead to interleaved output.

To Reproduce

// go code
go func1() {
   color.Warn.Tips("some text 1")
}()

go func2() {
   color.Error.Tips("some text 2")
}()

Expected behavior

concurrent calls can output correctly

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions