Junior — Senior
Simultaneous checking of a large list of domains with request limit
livecode
Task condition
It is necessary to modify the existing example so that the check of 1000 domains (function checkDomain) is performed in parallel, but the number of simultaneously running requests is limited (for example, no more than 100). After the check is completed, all domains for which checkDomain returned false should be displayed – that is, the "bad" domains.
import
"fmt"
func main () {
for _, val := range getData() {
if !checkDomain(val) {
fmt.Printf("%s is bad \n", val)
}
}
}
func getData () []string{
return [] string("1.test", "2.test", /.../ "1000.test")
}
func checkDomain(host string) bool {
return true
}
It is required to add a mechanism to limit the number of concurrently running goroutines (or an equivalent approach), collect the results of the checks, and display only those domains that did not pass the check.