←back to thread

Go subtleties

(harrisoncramer.me)
235 points darccio | 4 comments | | HN request time: 0.977s | source
1. fweimer ◴[] No.45671049[source]
Isn't using time.After for timeouts a bit of an anti-pattern? There is no way to cancel the pending computation.
replies(1): >>45671264 #
2. Philip-J-Fry ◴[] No.45671264[source]
This was fixed in Go 1.23 https://go.dev/doc/go1.23#timer-changes

They will get cleaned up.

replies(1): >>45671846 #
3. fweimer ◴[] No.45671846[source]
I meant that the goroutine in the example keeps running. Often this contradicts the reason for having the timeout in the first place.
replies(1): >>45673244 #
4. Philip-J-Fry ◴[] No.45673244{3}[source]
I'm not sure what you mean? The examples all return from their function.