kernel

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package kernel provides functions to read kernel parameters from the system.

Index

Constants

View Source
const DefaultCmdlinePath = "/proc/cmdline"

DefaultCmdlinePath is the default path to the kernel command line.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// ReadParameters reads and returns kernel parameters from the system.
	ReadParameters() (*Parameters, error)
}

Interface provides an interface for reading kernel parameters.

type InterfaceMock

type InterfaceMock struct {
	// ReadParametersFunc mocks the ReadParameters method.
	ReadParametersFunc func() (*Parameters, error)
	// contains filtered or unexported fields
}

InterfaceMock is a mock implementation of Interface.

func TestSomethingThatUsesInterface(t *testing.T) {

	// make and configure a mocked Interface
	mockedInterface := &InterfaceMock{
		ReadParametersFunc: func() (*Parameters, error) {
			panic("mock out the ReadParameters method")
		},
	}

	// use mockedInterface in code that requires Interface
	// and then make assertions.

}

func (*InterfaceMock) ReadParameters

func (mock *InterfaceMock) ReadParameters() (*Parameters, error)

ReadParameters calls ReadParametersFunc.

func (*InterfaceMock) ReadParametersCalls

func (mock *InterfaceMock) ReadParametersCalls() []struct {
}

ReadParametersCalls gets all the calls that were made to ReadParameters. Check the length with:

len(mockedInterface.ReadParametersCalls())

type Parameters

type Parameters struct {
	// CommandLine contains the raw kernel boot parameters from /proc/cmdline.
	CommandLine string
}

Parameters holds kernel boot parameters.

type SystemReader

type SystemReader struct {
	// contains filtered or unexported fields
}

SystemReader reads kernel parameters from the actual system files.

func NewSystemReader

func NewSystemReader() *SystemReader

NewSystemReader creates a new SystemReader with the default cmdline path.

func NewSystemReaderWithPath

func NewSystemReaderWithPath(cmdlinePath string) *SystemReader

NewSystemReaderWithPath creates a new SystemReader with a custom cmdline path. This is useful for testing.

func (*SystemReader) ReadParameters

func (r *SystemReader) ReadParameters() (*Parameters, error)

ReadParameters reads kernel parameters from /proc/cmdline and returns them as a Parameters struct with the raw command line content.

Jump to

Keyboard shortcuts

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