{"id":37164794,"url":"https://github.com/coolspring8/go-lolhtml","last_synced_at":"2026-01-14T19:33:54.429Z","repository":{"id":44125405,"uuid":"303606711","full_name":"CoolSpring8/go-lolhtml","owner":"CoolSpring8","description":"An idiomatic Go wrapper for Rust crate `lol-html` (Low Output Latency streaming HTML parser/rewriter)","archived":false,"fork":false,"pushed_at":"2020-11-03T08:12:34.000Z","size":7002,"stargazers_count":37,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-12T15:54:03.068Z","etag":null,"topics":["bindings","cgo","css-selector","html","html-parser","rewriting"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/coolspring8/go-lolhtml","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CoolSpring8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-13T06:18:52.000Z","updated_at":"2026-01-07T10:43:36.000Z","dependencies_parsed_at":"2022-09-26T18:41:04.791Z","dependency_job_id":null,"html_url":"https://github.com/CoolSpring8/go-lolhtml","commit_stats":null,"previous_names":["coolspring8/lolhtml"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/CoolSpring8/go-lolhtml","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoolSpring8%2Fgo-lolhtml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoolSpring8%2Fgo-lolhtml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoolSpring8%2Fgo-lolhtml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoolSpring8%2Fgo-lolhtml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CoolSpring8","download_url":"https://codeload.github.com/CoolSpring8/go-lolhtml/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoolSpring8%2Fgo-lolhtml/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28432629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bindings","cgo","css-selector","html","html-parser","rewriting"],"created_at":"2026-01-14T19:33:53.849Z","updated_at":"2026-01-14T19:33:54.414Z","avatar_url":"https://github.com/CoolSpring8.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-lolhtml\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/coolspring8/go-lolhtml/Go) [![codecov](https://codecov.io/gh/CoolSpring8/go-lolhtml/branch/main/graph/badge.svg)](https://codecov.io/gh/CoolSpring8/go-lolhtml) [![Go Report Card](https://goreportcard.com/badge/github.com/coolspring8/go-lolhtml)](https://goreportcard.com/report/github.com/coolspring8/go-lolhtml) [![PkgGoDev](https://pkg.go.dev/badge/github.com/coolspring8/go-lolhtml)](https://pkg.go.dev/github.com/coolspring8/go-lolhtml)\n\nGo bindings for the Rust crate [cloudflare/lol-html](https://github.com/cloudflare/lol-html/), the *Low Output Latency streaming HTML rewriter/parser with CSS-selector based API*, talking via cgo.\n\n**Status:** \n\n**All abilities provided by lol_html's c-api are available**, except for customized user data in handlers. The original tests included in c-api package have also been translated to examine this binding's functionality.\n\nThe code is at its early stage and **breaking changes might be introduced**. If you have any ideas on how the public API can be better structured, feel free to open a PR or an issue.\n\n   * [go-lolhtml](#go-lolhtml)\n      * [Installation](#installation)\n      * [Features](#features)\n      * [Getting Started](#getting-started)\n      * [Examples](#examples)\n      * [Documentation](#documentation)\n      * [Other Bindings](#other-bindings)\n      * [Versioning](#versioning)\n      * [Help Wanted!](#help-wanted)\n      * [License](#license)\n      * [Disclaimer](#disclaimer)\n\n## Installation\n\nFor Linux/macOS/Windows x86_64 platform users, installation is as simple as a single `go get` command:\n\n```shell\n$ go get github.com/coolspring8/go-lolhtml\n```\n\nInstalling Rust is not a necessary step. That's because lol-html could be prebuilt into static libraries, stored and shipped in `/build` folder, so that cgo can handle other compilation matters naturally and smoothly, without intervention.\n\nFor other platforms, you will have to compile it yourself.\n\n## Features\n\n- Fast: A Go (cgo) wrapper built around the highly-optimized Rust HTML parsing crate lol_html.\n- Easy to use: Utilizing Go's idiomatic I/O methods, [lolhtml.Writer](https://pkg.go.dev/github.com/coolspring8/go-lolhtml#Writer) implements [io.Writer](https://golang.org/pkg/io/#Writer) interface.\n\n## Getting Started\n\nNow let's initialize a project and create `main.go`:\n\n```go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"io\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/coolspring8/go-lolhtml\"\n)\n\nfunc main() {\n\tchunk := []byte(\"Hello, \u003cspan\u003eWorld\u003c/span\u003e!\")\n\tr := bytes.NewReader(chunk)\n\tw, err := lolhtml.NewWriter(\n\t\t// output to stdout\n\t\tos.Stdout,\n\t\t\u0026lolhtml.Handlers{\n\t\t\tElementContentHandler: []lolhtml.ElementContentHandler{\n\t\t\t\t{\n\t\t\t\t\tSelector: \"span\",\n\t\t\t\t\tElementHandler: func(e *lolhtml.Element) lolhtml.RewriterDirective {\n\t\t\t\t\t\terr := e.SetInnerContentAsText(\"LOL-HTML\")\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tlog.Fatal(err)\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn lolhtml.Continue\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// copy from the bytes reader to lolhtml writer\n\t_, err = io.Copy(w, r)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\t// explicitly close the writer and flush the remaining content\n\terr = w.Close()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\t// Output: Hello, \u003cspan\u003eLOL-HTML\u003c/span\u003e!\n}\n```\n\nThe above program creates a new Writer configured to rewrite all texts in `span` tags to \"LOL-HTML\". It takes the chunk `Hello, \u003cspan\u003eWorld\u003c/span\u003e!` as input, and prints the result to standard output.\n\nAnd the result is `Hello, \u003cspan\u003eLOL-HTML\u003c/span\u003e!` .\n\n## Examples\n\nexample_test.go contains two examples.\n\nFor more detailed examples, please visit the `/examples` subdirectory.\n\n- defer-scripts\n\n  Usage: curl -NL https://git.io/JeOSZ | go run main.go\n\n- mixed-content-rewriter\n\n  Usage: curl -NL https://git.io/JeOSZ | go run main.go\n\n- web-scraper\n\n  A ported Go version of https://web.scraper.workers.dev/.\n\n## Documentation\n\nAvailable at [pkg.go.dev](https://pkg.go.dev/github.com/coolspring8/go-lolhtml).\n\n## Other Bindings\n\n- Rust (native), C, JavaScript - [cloudflare/lol-html](https://github.com/cloudflare/lol-html/)\n- Lua - [jdesgats/lua-lolhtml](https://github.com/jdesgats/lua-lolhtml/)\n\n## Versioning\n\nThis package does not really follow [Semantic Versioning](https://semver.org/). The current strategy is to follow lol_html's major and minor version, and the patch version number is reserved for this binding's updates, for Go Modul to upgrade correctly.\n\n## Help Wanted!\n\nThere are a few interesting things at [Projects](https://github.com/coolspring8/go-lolhtml/projects/1) panel that I have considered but is not yet implemented. Other contributions and suggestions are also welcome!\n\n## License\n\nBSD 3-Clause \"New\" or \"Revised\" License\n\n## Disclaimer\n\nThis is an unofficial binding.\n\nCloudflare is a registered trademark of Cloudflare, Inc. Cloudflare names used in this project are for identification purposes only. The project is not associated in any way with Cloudflare Inc.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoolspring8%2Fgo-lolhtml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoolspring8%2Fgo-lolhtml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoolspring8%2Fgo-lolhtml/lists"}