Open DmitriyMV opened 5 months ago
use chan
use chan
That's creates unnecessary goroutines before we actually need them.
I think it's kinda confusing that this way you can bypass labels inheriting.
Is this an honest consequence of the more complicated truth about how the runtime handles timers? Part of the story seems like it's hinted at in this detail from AfterFunc:
AfterFunc waits for the duration to elapse and then calls f in its own goroutine.
Maybe it's a bit hand-wavy to say that this is enough documentation to reach a conclusion I think is fair (that this is an honest consequence).
How do other APIs that spawn goroutines on behalf of the caller behave? Do we propagate goroutine labels to them?
I could see this being the right behavior 90% of the time, but occasionally goroutines might be created on behalf of some other goroutine with other labels, and in that case it might be misleading. I don't really know what the right behavior should be for these kinds of APIs.
Go version
go version go1.22.3
or tip.What did you do?
Run this code: https://go.dev/play/p/Yf7N3XhKsdF?v=gotip
What did you see happen?
What did you expect to see?
I think it's kinda confusing that this way you can bypass labels inheriting.