Re:Waitgroups: What they are, how to use them and what chang...
by jeremyloy_wt on Saturday August 23, 2025 @01:01PM
(#44997301)
This isn’t necessary anymore as of Go 1.22
Re:Waitgroups: What they are, how to use them and what chang...
by 9rx on Saturday August 23, 2025 @01:10PM
(#44997396)
> This means you can't pass variables in as function arguments.
Well, you could...
for _, url := range urls {
wg.Go(func(u string) func() {
return func() {
http.Get(u)
}
}(url))
}
> You need to use this pattern insteadWhy? Seems rather redundant. It is not like WaitGroup.Go exists in earlier versions.
You need to use this pattern instead: