internal: split out linux specific bits into a separate package#1540
Merged
lmb merged 7 commits intocilium:mainfrom Aug 7, 2024
Merged
internal: split out linux specific bits into a separate package#1540lmb merged 7 commits intocilium:mainfrom
lmb merged 7 commits intocilium:mainfrom
Conversation
Pin and Unpin implement library-specific behaviour for BPF object pinning. Move it to package sys since that abstracts away BPF things. Signed-off-by: Lorenz Bauer <[email protected]>
Move some linux specific code out of package internal into package linux. As a rule of thumb, code probably belongs in this package if it calls into package unix. Signed-off-by: Lorenz Bauer <[email protected]>
Move Find to package linux, since it depends on deriving a file name from the current linux kernel version. This means that package kconfig only implements parsing of the kconfig format. Signed-off-by: Lorenz Bauer <[email protected]>
The two examples call into package unix which is not available
on non-Unix platforms. Add build tags so that
GOOS=windows go build ./...
works without errors.
Signed-off-by: Lorenz Bauer <[email protected]>
Signed-off-by: Lorenz Bauer <[email protected]>
Signed-off-by: Lorenz Bauer <[email protected]>
CI cross compiles the package and its tests for Darwin to make sure that it's possible to edit the source code on other Unix like platforms. Up the game a little and cross build for Windows instead of Darwin: this flushes out accidental uses of x/sys/unix instead of internal/unix. Signed-off-by: Lorenz Bauer <[email protected]>
rgo3
approved these changes
Aug 7, 2024
| "github.com/jsimonetti/rtnetlink/v2/driver" | ||
| "golang.org/x/sys/unix" | ||
|
|
||
| "github.com/cilium/ebpf" |
Contributor
There was a problem hiding this comment.
Should we add a linter that checks if imports are formatted correctly? Happy to open an issue!
Contributor
Author
There was a problem hiding this comment.
Yes, this could work: https://golangci-lint.run/usage/linters/#goimports with local set to the package url.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
internal: move Pin and Unpin to sys
internal: move linux specific code to separate package
internal/kconfig: move Find to package linux
examples: add linux build tag to uretprobe, ringbuf, socket_dist
program: use unix.SIGUSR1 in tests
link: use internal/unix in netkit tests
CI: cross build for Windows instead of Darwin