Closed danilopolani closed 7 years ago
Thank you for your PR!
SetDebug()
function seems like a good addition to the package. Found
as a field of Root
however, kind of deviates from what we were discussing in #7 . Instead, an Error
field returning an error (if occurred, nil
otherwise), seems to lean more, if not completely, towards idiomatic Go.
For example:
link := doc.Find("h2").Find("a")
if link.Error != nil {
// handle the error
}
Node
, Root
, FindNextSibling
, and FindPrevSibling
do need proper comments for documentation which I'll be looking into.
Yes, I thought about Error which is more Goish, but Found is more logic-driven (element found or not) as boolean, anyway tomorrow I'll change it to the error type.
After this PR, I have an idea about the other open issue, let's see if it works!
Ok, I replaced Found
with Error
and I updated the PR description. Let me know!
Looks good. Merged!
According to #7, with this merge you will be able to:
Error
field in theRoot
struct;SetDebug()
function. Default isfalse
, if set totrue
will show the variouspanic()
.Example to check if the node is found (no panic will appear in the terminal):
Example to check if the node is found with debug mode (panic will appear in terminal):
Notes:
Node
,Root
,FindNextSibling
andFindPrevSibling
needs edit on their comments.