Hello,

You use time.Sleep in your program, so the behavior is not predictable. In 
fact, I get it success or panic randomly.

You can see https://go-review.googlesource.com/c/sync/+/424114 to see a 
predictable test of ForgetUnshared .

On Wednesday, September 21, 2022 at 1:45:24 PM UTC+7 atomic wrote:

> hello
>
> I find that the `src/internal/singleflight/singleflight.go 
> ForgetUnshared()` method returns results that are not always expected
>
> For this I wrote a test code, I copied the code in the 
> src/internal/singleflight/singleflight.go file to the main package, and 
> wrote a main function to test it, if ForgetUnshared() returns correctly, 
> this code It should not panic, but the fact that it will panic every time 
> it runs, is there something wrong with my understanding of ForgetUnshared()?
>
> The test code cannot be run in goplay, so I posted a link: 
> https://gist.github.com/dchaofei/e07547bce17d94c3e05b1b2a7230f62f
>
> The go version I use for testing is 1.16, 1.19.1
>
> result:
> ```
> $ go run cmd/main.go
> panic: callUUID=[9314284969 <(931)%20428-4969>] err=[context canceled] 
> currentUUId=[6980556786]
> ```
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a528d3d5-d163-4626-a0a4-a33640392dedn%40googlegroups.com.

Reply via email to