Replies: 2 comments 1 reply
-
Can you try changing ident in the bpf2go invocation to have an uppercase? Something like |
Beta Was this translation helpful? Give feedback.
-
The issue you're facing is because the types generated by bpf2go aren't being exported (their names don't start with uppercase letters). In your bpf2go command, you're using a lowercase identifier
To solve your problem, change the identifier
This way, the generated types and functions will start with uppercase letters (e.g., For your desired project structure:
You can adjust the bpf2go command to use If you don't want to export all identifiers, you can use selective type aliasing in gen.go: package gen
// Only export the types you need
type Counter = counterObjects Hope this helps you resolve your issue! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
This is a noobie set of questions and i hope it does not come off as outlandish or ridiculous. I have recently started learning eBPF and using cilium's impl of it. I have been struggling to create a proper project structure such that I am able to import the generated code from bpf2go into my main.go.
The file system structure is included here

What I cannot figure out is why I am unable to import the generated functions. Any tips on this would be wonderful. For reference I have included the repo link.
My goal is to have my eBPF programs live in a separate package from the generated code, which should also be in its own separate package.
For example assume we have a project root of hello, I would want something like this:
hello/ebpf/counter.c
hello/gen/gen.go
hello/gen/counter_bpfeb.go
hello/gen/counter_bpfeb.o
hello/cmd/hello/main.go
If this structure is not possible what is the advisable structure for such a project?
Best,
Jacob
Beta Was this translation helpful? Give feedback.
All reactions