jroimartin / gocui

Minimalist Go package aimed at creating Console User Interfaces.
BSD 3-Clause "New" or "Revised" License
9.92k stars 608 forks source link

io.Copy(view, reader) #108

Closed alltom closed 7 years ago

alltom commented 7 years ago

I want to stream data to a view, and it seemed like the easiest way would be to write:

go func() { io.Copy(view, reader) }()

However, it looks like view.Write() isn't thread-safe.

Is the best way to accomplish this task to write my own Copy that wraps all writes in g.Execute()?

jroimartin commented 7 years ago

Yes, you are right. Write operations should be wrapped in g.Execute() to be thread-safe.