Skip to content

Commit

Permalink
Add version API (#125)
Browse files Browse the repository at this point in the history
The new defines `LIBBPF_MAJOR_VERSION` and `LIBBPF_MINOR_VERSION` have
been introduced in libbpf v0.6. We now expose their API as well.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
  • Loading branch information
saschagrunert committed Jan 31, 2022
1 parent 5e89006 commit 51cb51e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions libbpfgo.go
Expand Up @@ -95,6 +95,21 @@ const (
maxEventChannels = 512
)

// MajorVersion returns the major semver version of libbpf.
func MajorVersion() int {
return C.LIBBPF_MAJOR_VERSION
}

// MinorVersion returns the minor semver version of libbpf.
func MinorVersion() int {
return C.LIBBPF_MINOR_VERSION
}

// VersionString returns the string representation of the libbpf version.
func VersionString() string {
return fmt.Sprintf("v%d.%d", MajorVersion(), MinorVersion())
}

type Module struct {
obj *C.struct_bpf_object
links []*BPFLink
Expand Down

0 comments on commit 51cb51e

Please sign in to comment.