We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I wirte an go function to waiting some api responsed and then to do something,here is my code
func waitResponse(dashboardIds []int, page playwright.Page) { responses := [5]playwright.Response{} wg := sync.WaitGroup{} baseUrl := "https://example.com" for index, v := range dashboardIds { wg.Add(1) url := fmt.Sprintf("%s/%d?dashboard_id=114", baseUrl, v) idx := index v := v go func() { log.Printf("start request %s\n", url) // 1 response := page.WaitForResponse(url) log.Printf("goroutine get response from %s, index is %d\n", url,idx) // 2 resBody, _ := response.Body() responses[idx] = response defer wg.Done() }() page.On("response", func(res playwright.Response) { if res.URL() == url { log.Printf("listen get response from %s", url) //3 } }) } wg.Wait() log.Printf("all url responded") // 4 }
after run this function,I find 1、3 print every time,but 2 is only print one time(idx is 0), is there something wrong in my code?pls help me,thinks!
I want comment 4 could print
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I wirte an go function to waiting some api responsed and then to do something,here is my code
after run this function,I find 1、3 print every time,but 2 is only print one time(idx is 0), is there something wrong in my code?pls help me,thinks!
I want comment 4 could print
The text was updated successfully, but these errors were encountered: