Skip to content

Commit 564855d

Browse files
authored
Improve the documentation for Query
I noticed that my `InnerText` call resulted in a panic because `Query` returned a nil. I updated the `Query` doc to mention that it may return a nil `html.Node` with no error, and improved the overall wording a little
1 parent 44cd157 commit 564855d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

query.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ func QueryAll(top *html.Node, expr string) ([]*html.Node, error) {
5555
return nodes, nil
5656
}
5757

58-
// Query searches the html.Node that matches by the specified XPath expr,
59-
// and return the first element of matched html.Node.
58+
// Query runs the given XPath expression against the given html.Node and
59+
// returns the first matching html.Node, or nil if no matches are found.
6060
//
61-
// Return an error if the expression `expr` cannot be parsed.
61+
// Returns an error if the expression `expr` cannot be parsed.
6262
func Query(top *html.Node, expr string) (*html.Node, error) {
6363
exp, err := getQuery(expr)
6464
if err != nil {

0 commit comments

Comments
 (0)