{"id":50198135,"url":"https://github.com/boratanrikulu/gobee","last_synced_at":"2026-05-25T19:05:38.215Z","repository":{"id":355019676,"uuid":"1226409955","full_name":"boratanrikulu/gobee","owner":"boratanrikulu","description":"(WIP) The easiest way to build production eBPF apps in Go. gobee fills the BPF-program gap left by cilium/ebpf and bpf2go.","archived":false,"fork":false,"pushed_at":"2026-05-01T12:07:24.000Z","size":1145,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-01T14:09:56.687Z","etag":null,"topics":["bpf","cilium-ebpf","ebpf","golang","kernel","linux","transpiler"],"latest_commit_sha":null,"homepage":"","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/boratanrikulu.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-05-01T11:07:49.000Z","updated_at":"2026-05-01T13:25:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/boratanrikulu/gobee","commit_stats":null,"previous_names":["boratanrikulu/gobee"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/boratanrikulu/gobee","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boratanrikulu%2Fgobee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boratanrikulu%2Fgobee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boratanrikulu%2Fgobee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boratanrikulu%2Fgobee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boratanrikulu","download_url":"https://codeload.github.com/boratanrikulu/gobee/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boratanrikulu%2Fgobee/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33488991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-25T14:31:05.219Z","status":"ssl_error","status_checked_at":"2026-05-25T14:31:02.878Z","response_time":57,"last_error":"SSL_read: 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":["bpf","cilium-ebpf","ebpf","golang","kernel","linux","transpiler"],"created_at":"2026-05-25T19:05:35.005Z","updated_at":"2026-05-25T19:05:38.209Z","avatar_url":"https://github.com/boratanrikulu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gobee\n\n**Write your BPF programs in Go, not C.** gobee transpiles a strict subset of Go into BPF C, generates typed Go bindings for the userspace side, and gates loads against the running kernel.\n\nThe Go ecosystem has solid userspace tooling for BPF. The kernel side has always ended with \"now write your program in C.\" Aya brought eBPF to Rust by writing a new BPF backend in rustc. gobee gets there a different way: by transpiling to C and reusing clang's mature backend.\n\n## A Go file in, a BPF program out\n\nA tracepoint that streams every `execve` to userspace via a ringbuf:\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003cth\u003eYour input (Go)\u003c/th\u003e\n\u003cth\u003eWhat gobee emits (BPF C)\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\n```go\n//go:build ignore\n\npackage main\n\nimport \"github.com/boratanrikulu/gobee/bpf\"\n\n//bpf:license GPL\n\ntype Event struct {\n    Pid  uint32\n    Comm [16]byte\n}\n\nvar Events = bpf.RingBuf[Event]{\n    MaxEntries: 4096,\n}\n\n//bpf:section tracepoint/syscalls/sys_enter_execve\nfunc OnExec(ctx *bpf.ExecveEnterCtx) bpf.TpReturn {\n    e, ok := Events.Reserve()\n    if !ok {\n        return bpf.TpOk\n    }\n    e.Pid = bpf.GetCurrentPid()\n    bpf.GetTaskComm(\u0026e.Comm)\n    Events.Submit(e)\n    return bpf.TpOk\n}\n\nfunc main() {}\n```\n\n\u003c/td\u003e\n\u003ctd\u003e\n\n```c\n// Code generated by gobee. DO NOT EDIT.\n\n#include \"vmlinux.h\"\n#include \u003cbpf/bpf_helpers.h\u003e\n#include \u003cbpf/bpf_core_read.h\u003e\n\nchar _license[] SEC(\"license\") = \"GPL\";\n\nstruct Event {\n    __u32 Pid;\n    __u8 Comm[16];\n};\n\nstruct {\n    __uint(type, BPF_MAP_TYPE_RINGBUF);\n    __uint(max_entries, 4096);\n} Events SEC(\".maps\");\n\nSEC(\"tracepoint/syscalls/sys_enter_execve\")\nint OnExec(struct trace_event_raw_sys_enter *ctx) {\n    struct Event *e = bpf_ringbuf_reserve(\n        \u0026Events, sizeof(struct Event), 0);\n    if (!e) {\n        return 0;\n    }\n    e-\u003ePid = (__u32)(\n        bpf_get_current_pid_tgid() \u003e\u003e 32);\n    bpf_get_current_comm(\u0026e-\u003eComm, 16);\n    bpf_ringbuf_submit(e, 0);\n    return 0;\n}\n```\n\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n`gobee translate --bindings-dir ./bpf ./bpf/src` produces both files, plus a sourcemap (`events.bpf.c.map`) so verifier errors map back to Go lines and a typed bindings file (`bpf/events_bindings.go`) so the userspace driver writes `objs.Events`, `objs.AttachOnExec()`, and decodes ringbuf payloads straight into `bpf.Event` (the same struct you see above, re-published in Go) instead of stringly-typed `coll.Programs[\"...\"]` lookups.\n\nThe C is readable on purpose. If gobee emits something weird, you can see it. For tracepoints + kprobes + XDP combined into one binary, see [`example/sysmon/`](example/sysmon/).\n\n## How it compares\n\n| | gobee | C + clang + bpf2go | Aya (Rust) | bpftrace | BCC |\n|---|---|---|---|---|---|\n| Kernel-side language | Go subset | C | Rust | DSL | C |\n| Userspace integration | typed Go bindings + cilium/ebpf | bpf2go | aya-runtime | none | python |\n| CO-RE | ✅ via clang | ✅ | ✅ via LLVM | ✅ | ✅ |\n| Helper coverage | 200 typed Go wrappers | full (write C) | full | limited | full (write C) |\n| Verifier error → source | ✅ Go file:line:col | ❌ raw C | ✅ Rust file:line | ❌ | partial |\n| Kernel-version gate at load | ✅ via bpfvet | manual | manual | n/a | runtime |\n| Toolchain deps | Go + clang | clang + bpf2go | rustc + LLVM | bpftrace | python + bcc |\n| Generated artifact | `.bpf.o` + Go binary | `.bpf.o` + Go binary | `.bpf.o` + Rust binary | JIT | JIT |\n\nIf you're already in a C / libbpf workflow, gobee is not trying to replace it wholesale. It's for cases where you want the kernel side, the userspace side, and the build pipeline all in one Go module.\n\n## What's supported today\n\nSee [`docs/status.md`](docs/status.md) for the full matrix (Go subset, statements, expressions, every helper, every map type, every directive). Quick view:\n\n| Surface | Coverage |\n|---|---|\n| **Program types** (8) | XDP, tracepoint, kprobe / kretprobe, uprobe / uretprobe, sock_ops, TC, cgroup_skb, LSM |\n| **Map types** (19) | `array`, `hash`, `lru_hash`, per-CPU variants, `bloom_filter`, `lpm_trie`, `ringbuf`, `perf_event_array`, `prog_array`, `queue`, `stack`, sk/task/inode storage, devmap/cpumap/xskmap |\n| **BPF helpers** | ~200 typed Go stubs auto-generated from libbpf v1.5.0 headers. The ones exercised by `example/helloworld/` and `example/sysmon/` are tested in real-kernel CI; the rest are unverified. File an issue if a stub doesn't match the kernel signature |\n| **CO-RE** | ✅ auto-detected. `BPF_CORE_READ` for kernel-internal struct fields (`task_struct`, `sock`, `inode`); direct `ctx-\u003efield` for UAPI BPF context structs (`xdp_md`, `__sk_buff`, `bpf_sock_ops`). Exercised on Linux 6.x (Ubuntu 24.04 CI); older kernels not yet in the CI matrix |\n| **BTF-ready output** | ✅ emitted C includes `vmlinux.h` and uses `BPF_CORE_READ` for kernel-internal field reads, so the BTF clang generates from `clang -g` carries the right relocations. clang itself stays your responsibility (the example Makefiles show the canonical invocation) |\n| **User-defined helpers** | ✅ top-level Go funcs without `//bpf:section` are emitted as `static __always_inline` C functions |\n| **Typed Go bindings** | ✅ `Load\u003cStem\u003e`, `Close`, per-program `Attach\u003cName\u003e`, `AttachAll`, plus your kernel-side struct types and constants re-published in Go |\n| **Kernel-version gate** | ✅ [bpfvet](https://github.com/boratanrikulu/bpfvet) runs at load time. Fails fast with `bpf program needs kernel \u003e= 5.8, host is 5.4` instead of opaque `EINVAL` |\n| **Verifier error → Go source** | ✅ auto-annotated inside `Load\u003cStem\u003e`. No manual pipe to `gobee diagnose`; `*ebpf.VerifierError` comes back with `→ counter.go:18:5` markers |\n| **Sourcemap sidecar** | ✅ `\u003cstem\u003e.bpf.c.map` written next to every `.bpf.c` for offline `gobee diagnose` use too |\n| **Cross-arch** | ✅ Linux arm64 + amd64 |\n\n## What gobee does\n\n- Transpiles a Go subset to BPF C (and runs `go/types` over your input first, so misuses surface at `file:line:col`).\n- Generates a typed `\u003cStem\u003e_bindings.go` next to the `.bpf.c`: `bpf.LoadCounter(spec)`, `objs.PerIface.Lookup(...)`, `objs.AttachAll(ifindex)`, plus your kernel-side struct types and constants re-published in Go.\n- Auto-annotates `*ebpf.VerifierError` from `LoadAndAssign` with Go source positions, no manual `gobee diagnose` pipe needed.\n- Runs [bpfvet](https://github.com/boratanrikulu/bpfvet) inside `Load\u003cStem\u003e` so old kernels fail fast with `bpf program needs kernel \u003e= 5.8, host is 5.4`.\n- Surfaces ~200 typed Go stubs for the libbpf v1.5.0 helper set, plus user-defined helper functions emitted as `static __always_inline`.\n\n## What gobee won't do\n\n- **Replace clang.** clang's BPF backend gives us CO-RE, BTF, and verifier-friendly codegen for free. Reimplementing that costs years and gains nothing.\n- **Replace `cilium/ebpf`.** The generated bindings sit on top of it.\n- **Hide BPF.** The Go subset maps 1:1 to BPF C idioms. If you know BPF, gobee is thin sugar. If you don't, the manual is still required reading.\n- **Run clang for you.** Compile, embed, and load remain user-owned. Same pattern as bpf2go.\n\n## Why transpile, not generate BPF directly\n\n`gc`, the Go compiler, has no LLVM-based BPF backend. Adding one is a multi-year compiler project. `rustc` is built on LLVM and that's why Aya works. So gobee emits C and reuses clang's BPF backend, which gives us mature codegen, BTF, and CO-RE relocations for free.\n\n## Quickstart\n\n```bash\ngo install github.com/boratanrikulu/gobee/cmd/gobee@latest\n\ncd example/helloworld\nmake build                     # gobee translate, clang, go build\nsudo ./helloworld eth0\n```\n\nYou'll need clang with the BPF target. On Linux that's the distro package; on macOS, `brew install llvm`. The transpiler itself is pure Go and runs anywhere.\n\n## Project layout (typical)\n\n```\nyourproject/\n├── bpf/                      # Go package, importable from anywhere in your project\n│   ├── embed_amd64.go        # //go:embed bin/x86/your.bpf.o\n│   ├── embed_arm64.go\n│   ├── your_bindings.go      # generated by gobee\n│   ├── bin/{x86,arm64}/your.bpf.o\n│   └── src/                  # not a Go package; clang lives here\n│       ├── your.go           # //go:build ignore: BPF source\n│       ├── your.bpf.c        # generated\n│       ├── Makefile          # clang per arch\n│       └── vmlinux.h         # vendored BTF dump\n├── main.go                   # imports yourproject/bpf\n└── Makefile\n```\n\nThe split keeps `bpf/` a clean importable Go package (Go rejects `.c` files in non-cgo packages). Kernel sources and clang artifacts live one level down in `bpf/src/`.\n\n## Examples\n\n- `example/helloworld/`: the canonical XDP packet counter, ~40 lines BPF, ~80 lines userspace.\n- `example/sysmon/`: XDP, two tracepoints, and a kprobe in one binary, sharing a ringbuf for events. Demonstrates per-syscall typed contexts, user-defined helper functions, and the `AttachAll` shortcut.\n\n## CI\n\nGitHub Actions runs four layers on every push:\n\n1. `go test`, `go vet`, transpiler golden tests\n2. Coverage matrix: every map type and `//bpf:section` kind has at least one example\n3. clang compile of every curated example, then `bpfvet` portability report\n4. Real-kernel verifier acceptance: `ebpf.NewCollectionWithOptions` on each `.bpf.o` (Ubuntu 24.04 runner, kernel 6.x)\n\n## Docs\n\n- [`docs/design.md`](docs/design.md): architecture and rationale\n- [`docs/go-subset.md`](docs/go-subset.md): accepted Go syntax in BPF source files\n- [`docs/directives.md`](docs/directives.md): `//bpf:*` reference\n- [`docs/status.md`](docs/status.md): support matrix (single source of truth)\n\n## Toolchain\n\n- The gobee binary builds anywhere (pure Go, no CGO).\n- Compiling `.bpf.o` needs clang with the BPF target. Apple's bundled clang doesn't ship with it; on macOS use `brew install llvm` or build inside a Linux VM.\n- Running the artifact needs Linux on arm64 or amd64.\n\n## Inspirations\n\n- [Solod](https://github.com/solod-dev/solod): the Go-to-C transpiler that proved this pattern works.\n- [Aya](https://github.com/aya-rs/aya): the Rust eBPF framework whose ergonomics gobee chases.\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n\nCopyright (c) 2026 Bora Tanrikulu \u0026lt;me@bora.sh\u0026gt;\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboratanrikulu%2Fgobee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboratanrikulu%2Fgobee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboratanrikulu%2Fgobee/lists"}