{"id":50470428,"url":"https://github.com/v420v/ego","last_synced_at":"2026-06-01T10:02:22.483Z","repository":{"id":360136741,"uuid":"1235042811","full_name":"v420v/ego","owner":"v420v","description":"Go compiler for eBPF","archived":false,"fork":false,"pushed_at":"2026-05-25T05:47:51.000Z","size":226,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-25T07:25:09.833Z","etag":null,"topics":["compiler","ebpf","go"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/v420v.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"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-11T00:39:55.000Z","updated_at":"2026-05-25T05:47:55.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/v420v/ego","commit_stats":null,"previous_names":["v420v/ego"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/v420v/ego","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v420v%2Fego","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v420v%2Fego/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v420v%2Fego/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v420v%2Fego/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/v420v","download_url":"https://codeload.github.com/v420v/ego/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/v420v%2Fego/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33769492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["compiler","ebpf","go"],"created_at":"2026-06-01T10:02:21.687Z","updated_at":"2026-06-01T10:02:22.474Z","avatar_url":"https://github.com/v420v.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eGo - eBPF in Pure Go\n\n**Write eBPF programs in Go. Get a regular `.bpf.o` that any BPF loader can load.**\n\neGo is a Go-to-eBPF compiler. You write a subset of Go; it emits a\n`clang -target bpf`-compatible ELF object — BTF, CO-RE relocations, and\nall. The BPF backend, BTF encoder, and CO-RE relocator are all pure Go.\n\n```\nyour_program.go         ← //go:build ego\n       │ ego build\n       ▼\nyour_program.bpf.o      ← standard BPF ELF + BTF + CO-RE relocs\n       │ any BPF loader: libbpf (C), libbpf-rs / aya (Rust),\n       │ cilium/ebpf (Go), libbpf-python / bcc (Python), bpftool, …\n       ▼\nkernel: verifier → JIT → run\n```\n\neGo owns ELF emission. The output is a normal BPF ELF, so any existing loader in any language works. The examples in this repo use `cilium/ebpf`\nbecause the project is Go-leaning, but nothing about eGo's output is Go-specific.\n\n## Install\n\n```sh\ngo install github.com/v420v/ego/cmd/ego@latest\n```\n\nOr from source:\n```sh\nmake build       # → bin/ego\nmake examples    # build every example to .bpf.o\n```\n\n## Hello, XDP\n\n```go\n//go:build ego\npackage bpf\n\nimport (\n    \"github.com/v420v/ego/stdlib/maps\"\n    \"github.com/v420v/ego/stdlib/xdp\"\n)\n\nvar PacketCount = maps.PerCPUArray[uint64]{MaxEntries: 1}\n\n//ego:program type=xdp\nfunc Count(ctx *xdp.Context) xdp.Action {\n    var key uint32 = 0\n    if v := PacketCount.Lookup(\u0026key); v != nil {\n        *v = *v + 1\n    }\n    return xdp.Pass\n}\n```\n\nBuild:\n\n```sh\nego build -o counter.bpf.o ./path/to/pkg\n```\n\nLoad with whatever BPF loader you already use. Examples:\n\n```go\n// Go — github.com/cilium/ebpf\nspec, _ := ebpf.LoadCollectionSpec(\"counter.bpf.o\")\ncoll, _ := ebpf.NewCollection(spec)\ndefer coll.Close()\nl, _ := link.AttachXDP(link.XDPOptions{\n    Program: coll.Programs[\"Count\"], Interface: ifaceIdx,\n})\ndefer l.Close()\n```\n\n```c\n// C — libbpf\nstruct bpf_object *obj = bpf_object__open_file(\"counter.bpf.o\", NULL);\nbpf_object__load(obj);\nstruct bpf_program *prog = bpf_object__find_program_by_name(obj, \"Count\");\nbpf_program__attach_xdp(prog, ifindex);\n```\n\n```sh\n# Shell — bpftool, no userspace code at all\nbpftool prog loadall counter.bpf.o /sys/fs/bpf/counter\nbpftool net attach xdp pinned /sys/fs/bpf/counter/Count dev eth0\n```\n\nThe `.bpf.o` is the same standard ELF in every case.\n\n## License\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv420v%2Fego","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fv420v%2Fego","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fv420v%2Fego/lists"}