-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
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
proposal: x/net/html: add Node.FindAll #62219
Comments
See also #62113 |
how common is this? |
@seankhliao According to github code search there are about 2,600 places where the For me personally, it's the first time I'm parsing HTML with Go. It reduced code size once I wrote it. |
that search result might support #62113, but doesn't say much about needing a find variant |
If I add |
I think if #62113 is added, then this becomes unnecessary because it would be trivial to write |
OTOH, |
No, as proposed, doc.All() is an iterator, not a slice, so it’s quite different. It doesn’t allocate a slot for every child. |
Once we have iterators, we can implement |
Iterators are on track to release in February of 2024. The Go team aren't going to change the signature of a method in x/net/html after using it ~six months. |
Adding
node.FindAll(pred func(*Node) []*Node)
function will make using the code less lower level.Example usage:
A possible implementation is:
The text was updated successfully, but these errors were encountered: