goquery is a Go library for reading and manipulating HTML documents using a syntax taken from jQuery, the long-popular JavaScript library for browser scripting. The README's tagline calls it "a little like that j-thing, only in Go." If you know jQuery, you can use familiar selector strings like #id.class, or div > a to find parts of an HTML page, then chain methods on the result to read attributes, change text, or rearrange elements. The library is widely used in Go for scraping and parsing HTML. Internally, goquery is built on top of Go's standard net/html parser and a separate library called cascadia, which handles the CSS-selector matching. The README notes one consequence of this choice: net/html only returns a node tree rather than a full browser-style DOM, so jQuery's stateful methods that depend on layout, like height() and css(), are not provided. Another constraint is that net/html requires UTF-8 input, so callers have to convert other encodings before handing the HTML to goquery; the project wiki points to options for this. The README is mostly an installation section and a long changelog. Required Go versions have moved up over time: version 1.12.0 of goquery needs Go 1.25 or newer, version 1.11.0 needs Go 1.24 or newer, and earlier versions trace back through 1.23, 1.18, and 1.1, with the recent jumps driven by dependency updates and the adoption of generics and iterator functions. The author tests against the latest two Go releases. Installation is the usual go get of the package, with optional commands shown for running unit tests and benchmarks. The changelog entries also describe how the API has grown. Highlights from the README include a generic Map function, an EachIter method that exposes a Selection as a Go range iterator, a Render function that writes a Selection back to an io.Writer, Single and SingleMatcher helpers for first-match selection, parsing HTML in the context of the container node for methods like AppendHtml and AfterHtml, and an AttrOr helper that returns a default when an attribute is missing. A note states that the API is now considered stable and will not break. The README also mentions Matcher-based variants of the selector methods, which accept a pre-compiled cascadia selector so callers can handle compilation errors directly and reuse compiled selectors.
Generated 2026-05-21 · Model: sonnet-4-6 · Verify against the repo before relying on details.