inspector

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatJSON  = "json"
	FormatTable = "table"
)

OutputFormat constants

View Source
const (
	Reset     = "\033[0m"
	Bold      = "\033[1m"
	Dim       = "\033[2m"
	Italic    = "\033[3m"
	Underline = "\033[4m"

	// Foreground colors
	Black   = "\033[30m"
	Red     = "\033[31m"
	Green   = "\033[32m"
	Yellow  = "\033[33m"
	Blue    = "\033[34m"
	Magenta = "\033[35m"
	Cyan    = "\033[36m"
	White   = "\033[37m"

	// Bright foreground colors
	BrightBlack   = "\033[90m"
	BrightRed     = "\033[91m"
	BrightGreen   = "\033[92m"
	BrightYellow  = "\033[93m"
	BrightBlue    = "\033[94m"
	BrightMagenta = "\033[95m"
	BrightCyan    = "\033[96m"
	BrightWhite   = "\033[97m"

	// Background colors
	BgBlue  = "\033[44m"
	BgCyan  = "\033[46m"
	BgWhite = "\033[47m"
)

ANSI color codes

View Source
const (
	IconCPU         = "🖥️ "
	IconMemory      = "💾"
	IconProcess     = "⚙️ "
	IconCheck       = "✓"
	IconCross       = "✗"
	IconCircle      = "●"
	IconDiamond     = "◆"
	IconArrow       = "→"
	IconBar         = "█"
	IconBarLight    = "░"
	IconBarMed      = "▒"
	IconCore        = "◉"
	IconPID         = "⬡"
	IconStatus      = "◈"
	IconWarning     = "⚠️ "
	IconInfo        = "ℹ️ "
	IconLock        = "🔒"
	IconUnlock      = "🔓"
	IconKey         = "🔑"
	IconShield      = "🛡️ "
	IconFingerprint = "👆"
	IconFace        = "👤"
	IconApple       = "🍎"
	IconChip        = "🔲"
)

UTF-8 icons

Variables

This section is empty.

Functions

func BoldText

func BoldText(text string) string

Bold makes text bold

func BoolToCheckbox

func BoolToCheckbox(b bool) string

BoolToCheckbox returns a checkbox icon

func BoolToStatusColored

func BoolToStatusColored(b bool) string

BoolToStatusColored returns a colored status string

func Colorize

func Colorize(color, text string) string

Colorize wraps text with a color and reset

func Danger

func Danger(text string) string

Danger formats text as danger (red)

func DimText

func DimText(text string) string

Dim makes text dimmed

func FormatBiometricCapabilities

func FormatBiometricCapabilities(result *BiometricCapabilities, format string) string

FormatBiometricCapabilities is not available on unsupported platforms

func FormatBiometricCapabilitiesTable

func FormatBiometricCapabilitiesTable(result *BiometricCapabilities) string

FormatBiometricCapabilitiesTable is not available on unsupported platforms

func FormatBytes

func FormatBytes(bytes uint64) string

FormatBytes converts bytes to human-readable format

func FormatCPUUsage

func FormatCPUUsage(result *CPUUsageResult, format string) string

FormatCPUUsage formats CPU usage in the specified format

func FormatCPUUsageTable

func FormatCPUUsageTable(result *CPUUsageResult) string

FormatCPUUsageTable formats CPU usage as a colored table

func FormatMemory

func FormatMemory(result *MemoryResult, format string) string

FormatMemory formats memory usage in the specified format

func FormatMemoryTable

func FormatMemoryTable(result *MemoryResult) string

FormatMemoryTable formats memory usage as a colored table

func FormatOutput

func FormatOutput(data any, tableFunc func() string, format string) string

FormatOutput returns the result in the requested format (json or table)

func FormatProcessList

func FormatProcessList(result *ProcessListResult, format string) string

FormatProcessList formats process list in the specified format

func FormatProcessListTable

func FormatProcessListTable(result *ProcessListResult) string

FormatProcessListTable formats process list as a colored table

func FormatSecuritySummary

func FormatSecuritySummary(result *SecuritySummary, format string) string

FormatSecuritySummary formats security summary in the specified format

func FormatSecuritySummaryTable

func FormatSecuritySummaryTable(result *SecuritySummary) string

FormatSecuritySummaryTable formats security summary as a colored table

func Header(text string) string

Header formats text as a header (bold cyan)

func Info

func Info(text string) string

Info formats text as info (blue)

func IsBiometricsSupported

func IsBiometricsSupported() bool

IsBiometricsSupported returns false on unsupported platforms

func Muted

func Muted(text string) string

Muted formats text as muted (gray)

func PadLeft

func PadLeft(s string, width int) string

PadLeft pads a string to the left to reach the specified width

func PadRight

func PadRight(s string, width int) string

PadRight pads a string to the right to reach the specified width

func ProgressBar

func ProgressBar(percent float64, width int) string

ProgressBar creates a colored progress bar

func StripANSI

func StripANSI(s string) string

StripANSI removes ANSI escape codes from a string

func Success

func Success(text string) string

Success formats text as success (green)

func TableBottom

func TableBottom(widths ...int) string

TableBottom creates a bottom border for tables

func TableRow

func TableRow(cols ...string) string

TableRow creates a formatted table row with box-drawing characters

func TableRowColored

func TableRowColored(cols ...string) string

TableRowColored creates a colored table row

func TableSeparator

func TableSeparator(widths ...int) string

TableSeparator creates a separator line for tables

func TableTop

func TableTop(widths ...int) string

TableTop creates a top border for tables

func UsageColor

func UsageColor(percent float64) string

UsageColor returns the appropriate color based on usage percentage

func VisibleLen

func VisibleLen(s string) int

VisibleLen calculates the visible display width of a string (excluding ANSI codes and accounting for wide characters like emojis)

func Warning

func Warning(text string) string

Warning formats text as warning (yellow)

Types

type BioSummary

type BioSummary struct {
	Available  bool   `json:"available"`
	Configured bool   `json:"configured"`
	Type       string `json:"type"`
}

BioSummary contains biometrics summary info

type BiometricCapabilities

type BiometricCapabilities struct {
	TouchIDAvailable bool   `json:"touch_id_available"`
	TouchIDEnrolled  bool   `json:"touch_id_enrolled"`
	FaceIDAvailable  bool   `json:"face_id_available"`
	FaceIDEnrolled   bool   `json:"face_id_enrolled"`
	BiometryType     string `json:"biometry_type"`
	Platform         string `json:"platform"`
}

BiometricCapabilities contains detailed biometric capability information

func GetBiometricCapabilities

func GetBiometricCapabilities() (*BiometricCapabilities, error)

GetBiometricCapabilities returns an error on unsupported platforms

type BootSummary

type BootSummary struct {
	Enabled bool   `json:"enabled"`
	Mode    string `json:"mode"`
}

BootSummary contains Secure Boot summary info

type CPUUsageResult

type CPUUsageResult struct {
	UsagePercent float64   `json:"usage_percent"`
	PerCore      []float64 `json:"per_core"`
}

CPUUsageResult contains CPU usage information

func GetCPUUsage

func GetCPUUsage(ctx context.Context) (*CPUUsageResult, error)

GetCPUUsage returns current CPU usage

type EncSummary

type EncSummary struct {
	Enabled bool   `json:"enabled"`
	Type    string `json:"type"`
	Status  string `json:"status"`
}

EncSummary contains encryption summary info

type MemoryResult

type MemoryResult struct {
	TotalBytes     uint64  `json:"total_bytes"`
	UsedBytes      uint64  `json:"used_bytes"`
	FreeBytes      uint64  `json:"free_bytes"`
	AvailableBytes uint64  `json:"available_bytes"`
	UsedPercent    float64 `json:"used_percent"`
	TotalHuman     string  `json:"total_human"`
	UsedHuman      string  `json:"used_human"`
	AvailableHuman string  `json:"available_human"`
}

MemoryResult contains memory usage information

func GetMemory

func GetMemory(ctx context.Context) (*MemoryResult, error)

GetMemory returns current memory usage

type ProcessInfo

type ProcessInfo struct {
	PID           int32   `json:"pid"`
	Name          string  `json:"name"`
	CPUPercent    float64 `json:"cpu_percent"`
	MemoryPercent float32 `json:"memory_percent"`
	Status        string  `json:"status"`
}

ProcessInfo contains information about a single process

type ProcessListResult

type ProcessListResult struct {
	Processes []ProcessInfo `json:"processes"`
	Total     int           `json:"total"`
}

ProcessListResult contains the process list result

func ListProcesses

func ListProcesses(ctx context.Context, limit int) (*ProcessListResult, error)

ListProcesses returns a list of running processes

type SecuritySummary

type SecuritySummary struct {
	Platform        string       `json:"platform"`
	OverallScore    int          `json:"overall_score"`
	OverallStatus   string       `json:"overall_status"`
	TPM             *TPMSummary  `json:"tpm"`
	SecureBoot      *BootSummary `json:"secure_boot"`
	Encryption      *EncSummary  `json:"encryption"`
	Biometrics      *BioSummary  `json:"biometrics"`
	Recommendations []string     `json:"recommendations,omitempty"`
}

SecuritySummary contains a unified security posture overview

func GetSecuritySummary

func GetSecuritySummary() (*SecuritySummary, error)

GetSecuritySummary returns a unified security posture overview

type TPMSummary

type TPMSummary struct {
	Present bool   `json:"present"`
	Enabled bool   `json:"enabled"`
	Type    string `json:"type"`
}

TPMSummary contains TPM summary info

Jump to

Keyboard shortcuts

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