Core concepts of goquery
mastergoquery provides a syntax and feature set similar to jQuery for the Go language. It is built on top of Go's net/html package and the cascadia CSS selector library.
Key Mental Models
- DOM vs. Nodes: Unlike jQuery, which operates on a full-featured DOM tree, goquery is based on
net/htmlnodes. Consequently, stateful manipulation functions that rely on a full DOM (such asheight(),css(), ordetach()) are not available. - Encoding: goquery requires UTF-8 encoded HTML. It is the responsibility of the caller to ensure the source document is UTF-8 encoded.
- API Style: The library uses a chainable interface and attempts to maintain the same function names as jQuery where possible to provide a familiar developer experience.