You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This isn't a bug in workerpool, it's how go works.
for_, account:=rangeaccounts { // <- here you are assigning a pointer to a variable named accountfmt.Printf("loop %+v\n", account.Username) // <- you'll always get the expected answer herewp.Submit(func() {
// here, you are capturing the outer pointer to "account"// by the time this function is actually run, it may have a different value. That's your problem.fmt.Printf("go rountine %+v\n", account.Username)
})
}
This is actually clearly documented right in the sample:
Ubuntu 20.04 LTS
go version go1.19.3 linux/amd64
github.com/gammazero/workerpool v1.1.3
Here actual output
I was expecting
The text was updated successfully, but these errors were encountered: