Skip to content

v0.1.0

Latest
Compare
Choose a tag to compare
@tklauser tklauser released this 30 Oct 13:20
· 4 commits to main since this release
timeafter: skip check on Go ≥ 1.23

Go version ≥ 1.23 no longer has the issue of not collecting unstopped
Timers and time.After can safely be used in loops. Also see
https://go.dev/doc/go1.23#timer-changes and
https://cs.opensource.google/go/go/+/refs/tags/go1.23.2:src/time/sleep.go;l=196-201

Thus we can skip the timeafter check on modules with go.mod specifying
go1.23 or later.

Example run:

```
$ mkdir timeafter && cd timeafter
$ cat <<EOF > main.go
package main

import "time"

func main() {
	for {
		select {
		case <-time.After(5 * time.Second):
		}
	}
}
$ cat <<EOF > go.mod
module timeafter

go 1.22.0
EOF
$ linters .
/home/tklauser/tmp/timeafter/main.go:8:10: use of time.After in a for loop is prohibited, use inctimer instead
$ sed -ie 's/go 1\.22\.0/go 1.23.0/' go.mod
$ linters .
$
```

Signed-off-by: Tobias Klauser <[email protected]>