{"id":48707813,"url":"https://github.com/bnema/purego-cef","last_synced_at":"2026-04-25T07:06:32.463Z","repository":{"id":345369642,"uuid":"1165988515","full_name":"bnema/purego-cef","owner":"bnema","description":"Go bindings for the Chromium Embedded Framework C API, using purego instead of cgo.","archived":false,"fork":false,"pushed_at":"2026-04-20T10:49:34.000Z","size":2432,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-20T12:33:13.110Z","etag":null,"topics":["bindings","cef","chrome-embedded-framework","go","golang","purego"],"latest_commit_sha":null,"homepage":"https://github.com/bnema/purego-cef","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bnema.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-24T19:00:46.000Z","updated_at":"2026-04-20T08:23:29.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bnema/purego-cef","commit_stats":null,"previous_names":["bnema/purego-cef"],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/bnema/purego-cef","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnema%2Fpurego-cef","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnema%2Fpurego-cef/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnema%2Fpurego-cef/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnema%2Fpurego-cef/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bnema","download_url":"https://codeload.github.com/bnema/purego-cef/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bnema%2Fpurego-cef/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32253252,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T04:23:17.126Z","status":"ssl_error","status_checked_at":"2026-04-25T04:21:53.360Z","response_time":59,"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","cef","chrome-embedded-framework","go","golang","purego"],"created_at":"2026-04-11T12:09:06.511Z","updated_at":"2026-04-25T07:06:32.448Z","avatar_url":"https://github.com/bnema.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# purego-cef\n\nGo bindings for the [Chromium Embedded Framework](https://bitbucket.org/chromiumembedded/cef/) C API, using [purego](https://github.com/bnema/purego) instead of cgo.\n\nLinux only. `CGO_ENABLED=0`.\n\n\u003e [!NOTE]\n\u003e purego-cef is usable today, but it is still pre-1.0.\n\u003e Expect API changes while the handwritten `cef` layer settles.\n\n## Status\n\npurego-cef exposes the CEF C API through generated bindings and adds a smaller\nhandwritten `cef` layer for the common paths.\n\nWhat to expect today:\n- generated low-level bindings across the CEF C API\n- a smaller ergonomic `cef` layer for init, clients, and common handlers\n- shipped mocks for testing\n- ongoing API cleanup before 1.0\n\n## Architecture\n\nThe binding layer is **generated** from CEF C headers (~114 files). The generator parses all headers and produces:\n\n- **Inbound port interfaces** for every CEF handler and type\n- **Outbound port interfaces** grouping CEF free functions and object methods by domain\n- **A composite CAPI interface** embedding all outbound ports\n- **Typed constructors** for handlers and wrappers for CEF objects with automatic refcount management\n- **C struct layouts** and purego symbol registration\n- **Doc comments** extracted from CEF C headers\n\nThe public `cef` package then adds a small handwritten layer for the places\nwhere the raw C API is too awkward to expose directly.\n\nA hand-written core domain handles UTF-16 string conversion, reference counting, CEF lifecycle orchestration, and the Bridge adapter implementing the CAPI interface.\n\nMocks for all interfaces are generated by [Mockery v3](https://vektra.github.io/mockery/) and shipped in `cef/mocks/`.\n\n## API shape\n\nFor most code, prefer the ergonomic handwritten layer when it exists:\n\n- `cef.Settings` instead of `cef.RawSettings`\n- `cef.NewClient(...)` with `cef.Client`\n- `cef.NewLifeSpanHandler(...)` with `cef.LifeSpanHandler`\n- `cef.NewAudioHandler(...)` with the decoded `cef.AudioHandler` interface\n- `cef.ExecuteSubprocess()` when you want subprocess status and errors without\n  implicit `os.Exit` or `stderr` writes; `cef.MaybeExitSubprocess()` remains the\n  short helper for main packages\n- `cef.ExecuteSubprocessWithApp(app)` when helper subprocess startup also needs\n  a custom `cef.App`\n- `cef.LifeSpanHandler` popup callbacks receive a callback-scoped\n  `*cef.RawClientWriteSlot` when CEF exposes a writable popup client out-param;\n  check for nil before calling `Set` or `Clear`\n\nTreat `Raw*` types as advanced escape hatches.\n\n## Usage\n\nFor main packages, `cef.MaybeExitSubprocess()` is the short path. If you need\nexplicit subprocess status and error handling, use `cef.ExecuteSubprocess()` or\n`cef.ExecuteSubprocessWithApp(app)`.\n\n```go\npackage main\n\nimport (\n\t\"runtime\"\n\n\t\"github.com/bnema/purego-cef/cef\"\n)\n\nfunc main() {\n\truntime.LockOSThread()\n\tcef.MaybeExitSubprocess()\n\n\tif err := cef.Init(cef.DefaultSettings()); err != nil {\n\t\tpanic(err)\n\t}\n\tdefer cef.Shutdown()\n\n\tclient := cef.NewClient(myClient{})\n\t_ = client\n\n\t// Your render loop here\n\tfor {\n\t\tcef.DoMessageLoopWork()\n\t}\n}\n\n// Implement the user-facing client interface — only the methods you need.\ntype myClient struct{}\n\nfunc (c myClient) GetLifeSpanHandler() cef.LifeSpanHandler { return nil }\nfunc (c myClient) GetRenderHandler() cef.RenderHandler     { return myRenderer{} }\n// ... other handler getters return nil\n```\n\n## Requirements\n\n- Go 1.26+\n- CEF 145 runtime in `$CEF_DIR` or `~/.local/share/cef`\n\n## Building\n\n```\nCGO_ENABLED=0 go build ./...\nCGO_ENABLED=0 go test ./...\n```\n\nIntegration tests need the CEF runtime:\n\n```\nCEF_DIR=$HOME/.local/share/cef go test -tags=cef_integration ./integration\n```\n\n## Regenerating bindings\n\n```\ngo generate ./...\n```\n\nOr manually:\n\n```\ngo run ./cmd/cefgen \\\n  --headers-dir ~/.local/share/cef/include \\\n  --capi-dir internal/capi \\\n  --port-in-dir internal/ports/in \\\n  --port-out-dir internal/ports/out \\\n  --public-dir cef\nmockery\n```\n\n## Project layout\n\n```\ncef/                 public API (generated) + mocks\n  bridge.go          hand-written: handler constructors, string helpers\n  init.go            hand-written: Init(), Shutdown(), orchestration\ninternal/\n  ports/in/          inbound port interfaces (generated)\n  ports/out/         outbound port interfaces (generated) + composite CAPI (hand-written) + mocks\n  core/              domain logic: engine, string marshaling, refcount (hand-written)\n  capi/              purego bindings + bridge (generated + hand-written)\n  loader/            dlopen libcef.so + version validation (hand-written)\ncmd/cefgen/          binding generator (parser, model, emitter, templates)\nintegration/         integration tests (require CEF runtime)\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnema%2Fpurego-cef","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbnema%2Fpurego-cef","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbnema%2Fpurego-cef/lists"}