From 4e2643f318982fc7c31e280d3279d1ca8555dc87 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Fri, 26 Feb 2021 15:11:23 -0500 Subject: [PATCH] Make sure we pass our mutex by reference --- tea.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tea.go b/tea.go index dde6a56..1ac6504 100644 --- a/tea.go +++ b/tea.go @@ -100,7 +100,7 @@ func WithoutCatchPanics() ProgramOption { type Program struct { initialModel Model - mtx sync.Mutex + mtx *sync.Mutex output io.Writer // where to send output. this will usually be os.Stdout. input io.Reader // this will usually be os.Stdin. @@ -152,6 +152,7 @@ type hideCursorMsg struct{} // NewProgram creates a new Program. func NewProgram(model Model, opts ...ProgramOption) *Program { p := &Program{ + mtx: &sync.Mutex{}, initialModel: model, output: os.Stdout, input: os.Stdin, @@ -221,7 +222,7 @@ func (p *Program) Start() error { }() } - p.renderer = newRenderer(p.output, &p.mtx) + p.renderer = newRenderer(p.output, p.mtx) // Check if output is a TTY before entering raw mode, hiding the cursor and // so on.