Show HN: Write your BPF programs in Go, not C
Recorded: May 26, 2026, 1:15 p.m.
| Original | Summarized |
GitHub - boratanrikulu/gobee: Write your BPF programs in Go, not C. gobee transpiles a Go subset to BPF C and generates typed cilium/ebpf bindings. · GitHub Skip to content Navigation Menu Toggle navigation
Sign in
Appearance settings PlatformAI CODE CREATIONGitHub CopilotWrite better code with AIGitHub SparkBuild and deploy intelligent appsGitHub ModelsManage and compare promptsMCP RegistryNewIntegrate external toolsDEVELOPER WORKFLOWSActionsAutomate any workflowCodespacesInstant dev environmentsIssuesPlan and track workCode ReviewManage code changesAPPLICATION SECURITYGitHub Advanced SecurityFind and fix vulnerabilitiesCode securitySecure your code as you buildSecret protectionStop leaks before they startEXPLOREWhy GitHubDocumentationBlogChangelogMarketplaceView all featuresSolutionsBY COMPANY SIZEEnterprisesSmall and medium teamsStartupsNonprofitsBY USE CASEApp ModernizationDevSecOpsDevOpsCI/CDView all use casesBY INDUSTRYHealthcareFinancial servicesManufacturingGovernmentView all industriesView all solutionsResourcesEXPLORE BY TOPICAISoftware DevelopmentDevOpsSecurityView all topicsEXPLORE BY TYPECustomer storiesEvents & webinarsEbooks & reportsBusiness insightsGitHub SkillsSUPPORT & SERVICESDocumentationCustomer supportCommunity forumTrust centerPartnersView all resourcesOpen SourceCOMMUNITYGitHub SponsorsFund open source developersPROGRAMSSecurity LabMaintainer CommunityAcceleratorGitHub StarsArchive ProgramREPOSITORIESTopicsTrendingCollectionsEnterpriseENTERPRISE SOLUTIONSEnterprise platformAI-powered developer platformAVAILABLE ADD-ONSGitHub Advanced SecurityEnterprise-grade security featuresCopilot for BusinessEnterprise-grade AI featuresPremium SupportEnterprise-grade 24/7 supportPricing Search or jump to... Search code, repositories, users, issues, pull requests...
Search Clear
Search syntax tips Provide feedback Include my email address so I can be contacted Cancel Submit feedback Saved searches
Name Query To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up
Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. Dismiss alert boratanrikulu gobee Public
Notifications
Fork
Star Code Issues Pull requests Actions Projects Security and quality Insights
Additional navigation options
Code Issues Pull requests Actions Projects Security and quality Insights
mainBranchesTagsGo to fileCodeOpen more actions menuFolders and filesNameNameLast commit messageLast commit dateLatest commit History24 Commits24 Commits.github/workflows.github/workflows bpfbpf cmd/gobeecmd/gobee diagnosediagnose docsdocs e2ee2e exampleexample internal/transpileinternal/transpile testdatatestdata tools/genhelperstools/genhelpers .gitattributes.gitattributes .gitignore.gitignore LICENSELICENSE MakefileMakefile README.mdREADME.md go.modgo.mod go.sumgo.sum View all filesRepository files navigationREADMEMIT licensegobee Your input (Go) //go:build ignore package main import "github.com/boratanrikulu/gobee/bpf" //bpf:license GPL type Event struct { var Events = bpf.RingBuf[Event]{ //bpf:section tracepoint/syscalls/sys_enter_execve func main() {} // Code generated by gobee. DO NOT EDIT. #include "vmlinux.h" char _license[] SEC("license") = "GPL"; struct Event { struct { SEC("tracepoint/syscalls/sys_enter_execve") 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. gobee Kernel-side language Userspace integration CO-RE Helper coverage Verifier error → source Kernel-version gate at load Toolchain deps Generated artifact If 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. Surface Program types (8) Map types (19) BPF helpers CO-RE BTF-ready output User-defined helpers Typed Go bindings Kernel-version gate Verifier error → Go source Sourcemap sidecar Cross-arch What gobee does Transpiles a Go subset to BPF C (and runs go/types over your input first, so misuses surface at file:line:col). What gobee won't do Replace clang. clang's BPF backend gives us CO-RE, BTF, and verifier-friendly codegen for free. Reimplementing that costs years and gains nothing. Why transpile, not generate BPF directly cd example/helloworld The 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/. example/helloworld/: the canonical XDP packet counter, ~40 lines BPF, ~80 lines userspace. CI go test, go vet, transpiler golden tests Docs docs/design.md: architecture and rationale Toolchain The gobee binary builds anywhere (pure Go, no CGO). Inspirations Solod: the Go-to-C transpiler that proved this pattern works. License About Write your BPF programs in Go, not C. gobee transpiles a Go subset to BPF C and generates typed cilium/ebpf bindings. linux golang kernel transpiler ebpf bpf cilium-ebpf Resources Readme MIT license Uh oh! There was an error while loading. Please reload this page. Activity 214 1 1 Report repository Releases Packages
Uh oh! There was an error while loading. Please reload this page. Contributors Uh oh! There was an error while loading. Please reload this page. Languages Go Makefile
Footer © 2026 GitHub, Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. |
gobee is a tool designed to allow developers to write BPF programs in Go rather than the traditional C language, aiming to bridge the gap between the Go ecosystem and the kernel-side BPF development, which has historically relied on C. gobee achieves this by transpiling a strict subset of Go into BPF C code and subsequently generating typed Go bindings for the userspace side, integrated with cilium/ebpf. This approach leverages clang's mature backend to handle the complexities of BPF code generation, allowing users to maintain control over the compilation and loading process while benefiting from the ecosystem built around the LLVM infrastructure. The core functionality involves translating Go constructs into BPF C and generating associated bindings. For instance, a Go program defining an event structure and a tracepoint function is transpiled into BPF C code, which is then used to generate typed Go bindings that allow userspace drivers to directly interact with the BPF execution environment, such as reading data from ring buffers. This process allows users to define their logic in Go while utilizing the established capabilities of the C/Clang compilation pipeline. gobee’s design choices are informed by comparisons with existing workflows and frameworks. It seeks a middle ground compared to methods like C plus clang plus bpf2go, Rust’s Aya framework, bpftrace, and BCC. A significant feature of gobee is its adherence to Cross-Repository (CO-RE) principles, which is achieved via clang and LLVM, offering built-in support for better code relocation and verification. Furthermore, gobee automates critical aspects of BPF development, such as error handling, where verifier errors are automatically annotated with the corresponding line and column in the Go source, eliminating the need for manual diagnostic piping. Technically, gobee supports a rich set of BPF surface features, including eight program types, nineteen map types, and over two hundred typed Go stubs generated from the libbpf v1.5.0 header set for BPF helpers. The system incorporates a kernel-version gate using bpfvet, which ensures that BPF programs fail fast if the required kernel version is not met, thereby improving runtime stability. The generated output includes C source files alongside typed Go bindings, resulting in an artifact that is directly usable for userspace drivers while maintaining a traceable link back to the original Go source code. gobee focuses on transpilation rather than wholesale replacement of existing tools. It does not attempt to replace the clang backend or the entire cilium/ebpf framework; instead, it sits on top of these established technologies. This distinction means that while gobee handles the translation, the user remains responsible for the external compilation, embedding, and loading steps, maintaining the familiar pattern seen in other BPF toolchains. The supporting workflow involves a specific project layout where Go packages containing BPF definitions and Go code are separated from the kernel-side artifacts, which include the generated C source files and the relevant BTF dump, all within a structured directory. This setup facilitates automated testing through GitHub Actions, which verifies the transpiler, performs clang compilation, assesses portability through bpfvet reports, and validates execution by running the BPF programs against a real kernel environment. This comprehensive CI strategy ensures that the generated artifacts are robust and verifiable across different architectures. |