Below is a snippet of Go code that is missing some elements. This program is designed to run multiple tasks concurrently within a WaitGroup.
Fill in the blanks using the appropriate keywords and methods to make sure the program runs correctly.
Below is a snippet of Go code that is missing some elements. This program is designed to run multiple tasks concurrently within a WaitGroup.
Fill in the blanks using the appropriate keywords and methods to make sure the program runs correctly.
package main
import (
"fmt"
""
)
func main() {
var wg
for i := 0; i < 5; i++ {
wg.Add(1)
go func(id int) {
defer wg.
fmt.Printf("Goroutine %d is working\n", id)
}(i)
}
wg.()
fmt.Println("All goroutines have completed.")
}Create a free account to access the full topic