util

package
v1.300064.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLineLimitExceeded = errors.New("line limit exceeded")
)

Functions

func AbsPath added in v1.300062.0

func AbsPath(ctx context.Context, process detector.Process, path string) (string, error)

func BaseExe

func BaseExe(exe string) string

BaseExe returns the executable name from a path. Normalizes the name by removing file extensions and converting to lowercase to support cross-platform comparisons.

func BaseName added in v1.300062.0

func BaseName(path string) string

BaseName returns the base filename from a path. Removes quotes and deleted file indicators. Preserves file extensions and casing.

func IsValidPort

func IsValidPort(port int) bool

func NewCachedProcess

func NewCachedProcess(p detector.Process) detector.Process

func NewProcessWithPID

func NewProcessWithPID(process *process.Process) detector.Process

func ScanProperties added in v1.300062.0

func ScanProperties(r io.Reader, separator rune, fn func(key, value string) bool) error

ScanProperties parses key-value pairs from a reader and passes them to the fn. Returns early if fn returns false, the line limit is reached, or if the scanner has an error. Uses the defaultLineLimit.

func TrimQuotes

func TrimQuotes(s string) string

Types

type CachedProcess

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

CachedProcess provides a caching wrapper around the detector.Process. It caches the fields after their first retrieval.

func (*CachedProcess) CmdlineSliceWithContext

func (p *CachedProcess) CmdlineSliceWithContext(ctx context.Context) ([]string, error)

func (*CachedProcess) CreateTimeWithContext

func (p *CachedProcess) CreateTimeWithContext(ctx context.Context) (int64, error)

func (*CachedProcess) CwdWithContext

func (p *CachedProcess) CwdWithContext(ctx context.Context) (string, error)

func (*CachedProcess) EnvironWithContext

func (p *CachedProcess) EnvironWithContext(ctx context.Context) ([]string, error)

func (*CachedProcess) ExeWithContext

func (p *CachedProcess) ExeWithContext(ctx context.Context) (string, error)

func (*CachedProcess) OpenFilesWithContext added in v1.300062.0

func (p *CachedProcess) OpenFilesWithContext(ctx context.Context) ([]detector.OpenFilesStat, error)

func (*CachedProcess) PID

func (p *CachedProcess) PID() int32

type ProcessWithPID

type ProcessWithPID struct {
	*process.Process
}

ProcessWithPID provides a wrapper for the gopsutil process.Process to expose the PID.

func (*ProcessWithPID) PID

func (p *ProcessWithPID) PID() int32

Jump to

Keyboard shortcuts

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