We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go version
$ go version go version go1.20.4 darwin/amd64
Yes
go env
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/rudolfszvejs/Library/Caches/go-build" GOENV="/Users/rudolfszvejs/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/rudolfszvejs/go/pkg/mod" GONOPROXY="code.tdlbox.com" GONOSUMDB="code.tdlbox.com" GOOS="darwin" GOPATH="/Users/rudolfszvejs/go" GOPRIVATE="code.tdlbox.com" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/Cellar/go/1.20.4/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/Cellar/go/1.20.4/libexec/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.20.4" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="cc" CXX="c++" CGO_ENABLED="1" GOMOD="/Users/rudolfszvejs/go/src/code.tdlbox.com/loadero/rnd/sales-scrapper/go.mod" GOWORK="" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-l ength=0 -fdebug-prefix-map=/var/folders/65/207sntgd6rjcr3bxl5zctw9m0000gn/T/go-build3662304365=/tm p/go-build -gno-record-gcc-switches -fno-common"
timer := time.AfterFunc(time.Second, func() { time.Sleep(5 * time.Second) }) time.Sleep(2 * time.Second) if !timer.Stop() { <-timer.C }
Creating a new Timer via AfterFunc does not initialize the Timer.C field, making the code above deadlock. Link to go.dev/play
Timer
AfterFunc
Timer.C
Documentation clearly specifying that Timer.C shouldn't be used when Timer is created using AfterFunc.
In the documentation, there are multiple examples of
if !timer.Stop() { <-timer.C }
making me think that Timer.C is always available.
The text was updated successfully, but these errors were encountered:
@Nasfame For plain text please use plain text, not an image. Images can be very difficult to read. Thanks.
Sorry, something went wrong.
Change https://go.dev/cl/503922 mentions this issue: time: document that AfterFunc Timer's C field is nil
time: document that AfterFunc Timer's C field is nil
It seems it's not a good practice to just make an exception here without changing the structure of structs and funcs. How did it go with this issue?
@AMK9978 I'm sorry, I don't understand the question.
I've sent a patch to improve the documentation in https://go.dev/cl/503922. It's waiting for review.
16ec514
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Creating a new
Timer
viaAfterFunc
does not initialize theTimer.C
field, making the code above deadlock. Link to go.dev/playWhat did you expect to see?
Documentation clearly specifying that
Timer.C
shouldn't be used whenTimer
is created usingAfterFunc
.What did you see instead?
In the documentation, there are multiple examples of
making me think that
Timer.C
is always available.The text was updated successfully, but these errors were encountered: