commit 41fbbc2f62efa4c78dc3c33fd55cd01e42c67f8e
parent c6f10d13d6fbaf0ca6c8c4a68fc9130d8c09f839
Author: Lukas Henkel <lh@entf.net>
Date: Fri, 19 Feb 2021 21:03:39 +0100
Close the channel
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/htmltools.go b/htmltools.go
@@ -62,7 +62,10 @@ func findRecursive(node *html.Node, nodeFunc func(*html.Node) bool, ch chan<- *h
// the whole document. If nodeFunc is `nil`, all nodes match.
func FindRecursive(doc *html.Node, nodeFunc NodeMatchFunc) <-chan *html.Node {
ch := make(chan *html.Node)
- go findRecursive(doc, nodeFunc, ch)
+ go func() {
+ findRecursive(doc, nodeFunc, ch)
+ close(ch)
+ }()
return ch
}