How to break out goquery Each loop in Go
您能帮我打破一个goquery循环吗?
我使用了" return \\",但是它并没有跳出循环,只需传递迭代即可...
我如何在以下代码中中断"每个"循环:
1 2 3 4 5 6 | doc.Find("td").Each(func(i int, s *goquery.Selection) { summary := s.Text() if summary =="--" { //I want to break the Each loop here } } |
使用
1 2 3 4 5 6 7 | doc.Find("td").EachWithBreak(func(i int, s *goquery.Selection) bool { summary := s.Text() if summary =="--" { return false } return true }) |