From ef4963435320a8c8313147d0d9f68bfa130dc182 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 21 Sep 2022 19:10:57 +0530 Subject: [PATCH] Fix some issues reported by staticcheck --- tools/tui/loop/read.go | 1 - tools/tui/loop/write.go | 6 ++---- tools/utils/style/indent-and-wrap.go | 2 +- tools/utils/utf-8.go | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tools/tui/loop/read.go b/tools/tui/loop/read.go index 804f04f55..f95c61006 100644 --- a/tools/tui/loop/read.go +++ b/tools/tui/loop/read.go @@ -93,7 +93,6 @@ func read_from_tty(pipe_r *os.File, term *tty.Term, results_channel chan<- []byt case results_channel <- send: case <-quit_channel: keep_going = false - break } } } diff --git a/tools/tui/loop/write.go b/tools/tui/loop/write.go index fdd17e293..1062034a4 100644 --- a/tools/tui/loop/write.go +++ b/tools/tui/loop/write.go @@ -209,7 +209,7 @@ func flush_writer(pipe_w *os.File, tty_write_channel chan<- *write_msg, write_do }() deadline := time.Now().Add(timeout) for len(pending_writes) > 0 && !writer_quit { - timeout = deadline.Sub(time.Now()) + timeout = time.Until(deadline) if timeout <= 0 { return } @@ -219,7 +219,6 @@ func flush_writer(pipe_w *os.File, tty_write_channel chan<- *write_msg, write_do case _, more := <-write_done_channel: if !more { writer_quit = true - break } case tty_write_channel <- pending_writes[0]: pending_writes = pending_writes[1:] @@ -227,7 +226,7 @@ func flush_writer(pipe_w *os.File, tty_write_channel chan<- *write_msg, write_do } close(tty_write_channel) tty_write_channel = nil - timeout = deadline.Sub(time.Now()) + timeout = time.Until(deadline) if timeout <= 0 { return } @@ -241,5 +240,4 @@ func flush_writer(pipe_w *os.File, tty_write_channel chan<- *write_msg, write_do return } } - return } diff --git a/tools/utils/style/indent-and-wrap.go b/tools/utils/style/indent-and-wrap.go index 90940cb3a..8d083514f 100644 --- a/tools/utils/style/indent-and-wrap.go +++ b/tools/utils/style/indent-and-wrap.go @@ -230,7 +230,7 @@ func (self *hyperlink_state) apply_osc(raw string) { self.url = parts[2] } -func (self hyperlink_state) reset() { +func (self *hyperlink_state) reset() { self.id = "" self.url = "" } diff --git a/tools/utils/utf-8.go b/tools/utils/utf-8.go index 39c3d1b29..27cd73974 100644 --- a/tools/utils/utf-8.go +++ b/tools/utils/utf-8.go @@ -25,7 +25,7 @@ var utf8_data []uint8 = []uint8{ const ( UTF8_ACCEPT UTF8State = 0 - UTF8_REJECT = 1 + UTF8_REJECT UTF8State = 1 ) func DecodeUtf8(state *UTF8State, codep *UTF8State, byte_ byte) UTF8State {