diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-13 02:42:56 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-04-13 08:19:01 -0600 |
commit | f4d10a92abc46bf0156ff1b475304471c16405da (patch) | |
tree | 1c7dd77840d8b0851b58d4a1faf90ccd0da1805a /lib/streamio/runescanner.go | |
parent | b35aa24d868637332c1ba804a12911445a5a664b (diff) |
Try to find misuses of textui.Progress
- Add a runtime-check to Progress to notice if we deadlocked or
forgot to call .Done().
- Add a runtime-check to Progress.Done() to panic if .Set() was never
called (instead of the old behavior of deadlocking).
- grep: Use `defer` when possible, to help remember to call .Done().
- grep: Always either call .Set() right away, or right before calling
.Done().
Diffstat (limited to 'lib/streamio/runescanner.go')
-rw-r--r-- | lib/streamio/runescanner.go | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/streamio/runescanner.go b/lib/streamio/runescanner.go index 203439f..1206522 100644 --- a/lib/streamio/runescanner.go +++ b/lib/streamio/runescanner.go @@ -103,6 +103,7 @@ func (rs *runeScanner) UnreadRune() error { // ReadRune implements io.Closer. func (rs *runeScanner) Close() error { + rs.progressWriter.Set(rs.progress) rs.progressWriter.Done() return rs.closer.Close() } |