config

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chroot

func Chroot(ctx context.Context) string

Chroot gets a context's chroot override or the default if none is set.

func ContextFromArgs

func ContextFromArgs(args ...any) context.Context

ContextFromArgs returns a context.Context populated with any old-style options or new-style arguments.

func ContextFromEnv

func ContextFromEnv() context.Context

ContextFromEnv returns a new context.Context populated from the environs or default option values

func EnvOrDefaultChroot

func EnvOrDefaultChroot() string

EnvOrDefaultChroot returns the value of the GHW_CHROOT environs variable or the default value of "/" if not set

func EnvOrDefaultDisableTools

func EnvOrDefaultDisableTools() bool

EnvOrDefaultDisableTools return true if ghw should use external tools to augment the data collected from sysfs. Most users want to do this most of time, so this is enabled by default. Users consuming snapshots may want to opt out, thus they can set the GHW_DISABLE_TOOLS environs variable to any value to make ghw skip calling external tools even if they are available.

func EnvOrDefaultDisableWarnings

func EnvOrDefaultDisableWarnings() bool

EnvOrDefaultDisableWarnings return true if ghw should not output warnings based on the GHW_DISABLE_WARNINGS environs variable.

func EnvOrDefaultEnableTopology

func EnvOrDefaultEnableTopology() bool

EnvOrDefaultEnableTopology return true if ghw should detect system topology.

func EnvOrDefaultLogLevel

func EnvOrDefaultLogLevel() slog.Level

EnvOrDefaultLogLevel return true if ghw should not output warnings based on the GHW_LOG_LEVEL environs variable.

func EnvOrDefaultLogLogfmt

func EnvOrDefaultLogLogfmt() bool

EnvOrDefaultLogLogfmt return true if ghw should use logfmt standard output format based on the GHW_LOG_LOGFMT environs variable.

func LogLevel

func LogLevel(ctx context.Context) slog.Level

LogLevel gets a context's logger's log level or the default if none is set.

func Logger

func Logger(ctx context.Context) *slog.Logger

Logger gets a context's logger override or the default if none is set.

func PCIDB

func PCIDB(ctx context.Context) *pcidb.PCIDB

PCIDB returns any PCIDB pointer set in the supplied context.

func PathOverrides

func PathOverrides(ctx context.Context) map[string]string

PathOverrides returns any path overrides set in the supplied context.

func ToolsEnabled

func ToolsEnabled(ctx context.Context) bool

ToolsEnabled returns true if external tools have been disabled.

func TopologyEnabled

func TopologyEnabled(ctx context.Context) bool

TopologyEnabled returns true if the detection of system topology is enabled.

Types

type Key

type Key string

type Modifier

type Modifier func(context.Context) context.Context

Modifier sets some value on the context

func WithChroot

func WithChroot(path string) Modifier

WithChroot allows overriding the root directory ghw examines.

func WithDebug

func WithDebug() Modifier

WithDebug enables verbose debugging output.

func WithDisableTools

func WithDisableTools() Modifier

WithDisableTools prevents ghw from calling external tools to discover hardware capabilities.

func WithDisableTopology

func WithDisableTopology() Modifier

WithDisableTopology disables system topology detection to reduce memory consumption. When using this option, ghw will skip scanning NUMA topology, CPU cores, memory caches, and node distances. This is useful when you only need basic PCI or GPU information and want to minimize memory overhead. The system architecture will be assumed to be SMP, and device Node fields will be nil.

func WithDisableWarnings

func WithDisableWarnings() Modifier

WithDisableWarnings tells ghw not to output warning messages.

func WithLogLevel

func WithLogLevel(level slog.Level) Modifier

WithLogLevel allows overriding the default log level of WARN.

func WithLogLogfmt

func WithLogLogfmt() Modifier

WithLogLogfmt sets the log output to the logfmt standard.

func WithLogger

func WithLogger(logger *slog.Logger) Modifier

WithLogger allows overriding the default logger

func WithPCIDB

func WithPCIDB(db *pcidb.PCIDB) Modifier

WithPCIDB allows you to provide a custom instance of the PCI database (pcidb.PCIDB) to ghw. This is useful if you want to use a preloaded or specially configured PCI database, such as one created with custom pcidb.WithOption settings, instead of letting ghw load the PCI database automatically.

func WithPathOverrides

func WithPathOverrides(overrides map[string]string) Modifier

WithPathOverrides supplies path-specific overrides for the context

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL