i have function main
func main() {
response, err := http.Get(geturl)
if err != nil {
fmt.Print(err.Error())
os.Exit(1)
}
responseData, err := ioutil.ReadAll(response.Body)
if err != nil {
log.Fatal(err)
}
values := gjson.Get(string(responseData), "items")
rl := ratelimit.New(3)
prev := time.Now()
values.ForEach(func(_, v gjson.Result) bool {
now := rl.Take()
url := v.Get("url").String()
resp, err := http.Post(url, "application/x-www-form-urlencoded", nil)
.......
.........
............
return true
})
defer time.AfterFunc(3*time.Second, main())
}
Calling function main after timeout not working…
But at all is it right solution to repeat the for loop for new result from geturl
?
And why the main()
not called after timeout?
also can i improve the perfomance of the foreach loop with goroutines? does goroutines helpful here in this case?