Skip to content

Why no New from a Reader or String? #20

Closed
jweir opened this Issue Sep 3, 2013 · 3 comments

2 participants

@jweir
jweir commented Sep 3, 2013

I am using goquery to scan existing HTML files. These aren't created from a response. And I don't want to expose go.net/html to my application.

A NewFromString or NewFromReader would be great... or just a simple New

func New(src io.Reader) (d *Document, e error){
    // Parse the HTML into nodes
    root, e := html.Parse(src)
    if e != nil {
        return
    }

    // Create and fill the document
    d = newDocument(root, nil)
    return
}

BTW nice library, thank you very much.

@PuerkitoBio
Owner

I'll add it, probably this week-end.

@jweir jweir added a commit to jweir/goquery that referenced this issue Sep 5, 2013
@jweir jweir New constructor from a Reader #20 d32d3d4
@jweir jweir added a commit to jweir/goquery that referenced this issue Sep 5, 2013
@jweir jweir Fix signature for #20 c2a69ca
@jweir
jweir commented Sep 5, 2013

Pushed the above if you are interested. It might not be the naming convention you want to follow.

@PuerkitoBio
Owner

Thanks, but I followed the NewDocumentFromX naming even though it would have been a good candidate for simply New, but it would have been ambiguous with the existing NewDocument. I don't want to make breaking changes at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.