1
0
mirror of https://github.com/mgechev/revive.git synced 2025-10-30 23:37:49 +02:00
Files
revive/rule
Abhinav Gupta b03e54f617 empty-block: Fix false positive on select {} (#805)
This fixes a false positive reported by revive on the following:

    select {}

This is a way to block the program indefinitely.
It is used in cases like:

- Running a long-running server in a background thread
  and blocking `main` from exiting until the application dies.
  This is something you might do if your process has
  multiple servers/listeners in the same process.

  ```go
  go grpcListenAndServe()
  go httpListenAndServe()
  go logFlusher()

  select {}
  ```

- In programs compiled to WASM to prevent the application from exiting,
  so that the Javascript components may interact with it.

  ```go
  func main() {
    js.Global().Set("foo", foo)
    select {}
  }
  ```

  Without this, one may see an error like,
  "Error: Go program has already exited"

As a workaround, these programs can block forever
by receiving from a throwaway channel (`<-make(chan struct{})`),
but `select {}` is still a completely valid way of doing this,
so supporting it makes sense.

The issue was previously reported in #698 but was closed
because the author was satisfied with a `//nolint` comment.

Now that this rule is part of the default rule set (#799)
the case for addressing the false positive is stronger.

Resolves #804
2023-03-16 13:39:52 -07:00
..
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-18 09:45:42 -07:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-06-28 18:14:26 +03:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-09-10 09:08:17 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2023-01-26 13:50:35 -08:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2023-02-18 10:57:06 +01:00
2022-04-10 11:55:13 +02:00
2023-03-14 16:16:12 -07:00
2022-04-10 11:55:13 +02:00
2021-10-01 13:55:53 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00
2022-04-10 11:55:13 +02:00