package platform

import "github.com/cilium/ebpf/internal/platform"

Index

Constants

const (
	LinuxTag = uint32(iota) << platformShift
	WindowsTag
)

Values used to tag platform specific constants.

The value for Linux is zero so that existing constants do not change.

const (
	Linux   = "linux"
	Windows = "windows"
)
const (
	IsLinux   = runtime.GOOS == "linux"
	IsWindows = runtime.GOOS == "windows"
)
const Native = Linux

Functions

func DecodeConstant

func DecodeConstant[T ~uint32](c T) (string, uint32)

Decode a platform and a value from a tagged constant.

func EncodeConstant

func EncodeConstant[T ~uint32](platform string, c uint32) (T, error)

Encode a platform and a value into a tagged constant.

Returns an error if platform is unknown or c is out of bounds.

func SelectVersion

func SelectVersion(versions []string) (string, error)

SelectVersion extracts the platform-appropriate version from a list of strings like `linux:6.1` or `windows:0.20.0`.

Returns an empty string and nil if no version matched or an error if no strings were passed.

Source Files

constants.go platform.go platform_linux.go

Version
v0.18.0 (latest)
Published
Apr 2, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
6 days ago

Tools for package owners.