diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-17 08:06:10 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-17 08:06:10 +0200 |
| commit | c680422366d7a4fc358917b8c8af5dd5bae792ae (patch) | |
| tree | 69e6f787e8d5a2432a2b044dceaf3749d7938b52 /internal/display/display.go | |
| parent | 41e25da4ccb3121ee9d22f8e9ad48568241d897c (diff) | |
Align codebase with Go best practices (ordering and style)v0.10.1
- Fix struct field alignment in Config and runState
- Move parseBool() after Config methods (group methods together)
- Move interface satisfaction checks after type definitions in store.go
- Move linkScales var to top of display.go with other declarations
- Clean up orphaned comment and blank line
- Bump version to 0.10.1
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/display/display.go')
| -rw-r--r-- | internal/display/display.go | 59 |
1 files changed, 28 insertions, 31 deletions
diff --git a/internal/display/display.go b/internal/display/display.go index d3f27ca..d31bdcb 100644 --- a/internal/display/display.go +++ b/internal/display/display.go @@ -19,43 +19,47 @@ import ( const smoothFactor = 0.12 // blend toward target each frame; lower = smoother +// linkScales lists the supported network link speeds in ascending order, +// used by the f/v hotkeys to cycle through link scale values. +var linkScales = []string{"mbit", "10mbit", "100mbit", "gbit", "10gbit"} + // runState holds mutable state across the display loop (hotkeys, window size, smoothed data). type runState struct { - showAvgLine bool - showIOAvgLine bool - showCores bool - showMem bool + showAvgLine bool + showIOAvgLine bool + showCores bool + showMem bool showNet bool showSeparators bool extended bool - winW int32 - winH int32 - prevCPU map[string]collector.CPULine - smoothedCPU map[string]*[10]float64 - smoothedMem map[string]*struct{ ramUsed, swapUsed float64 } - smoothedNet map[string]*struct{ rxPct, txPct float64 } - prevNet map[string]stats.NetStamp // aggregated (summed) previous net stamp per host - peakHistory map[string][]float64 + winW int32 + winH int32 + prevCPU map[string]collector.CPULine + smoothedCPU map[string]*[10]float64 + smoothedMem map[string]*struct{ ramUsed, swapUsed float64 } + smoothedNet map[string]*struct{ rxPct, txPct float64 } + prevNet map[string]stats.NetStamp // aggregated (summed) previous net stamp per host + peakHistory map[string][]float64 } // newRunState builds initial run state from config. func newRunState(cfg *config.Config, winW, winH int32) *runState { return &runState{ - showAvgLine: cfg.ShowAvgLine, - showIOAvgLine: cfg.ShowIOAvgLine, - showCores: cfg.ShowCores, - showMem: cfg.ShowMem, + showAvgLine: cfg.ShowAvgLine, + showIOAvgLine: cfg.ShowIOAvgLine, + showCores: cfg.ShowCores, + showMem: cfg.ShowMem, showNet: cfg.ShowNet, showSeparators: cfg.ShowSeparators, extended: cfg.Extended, - winW: winW, - winH: winH, - prevCPU: make(map[string]collector.CPULine), - smoothedCPU: make(map[string]*[10]float64), - smoothedMem: make(map[string]*struct{ ramUsed, swapUsed float64 }), - smoothedNet: make(map[string]*struct{ rxPct, txPct float64 }), - prevNet: make(map[string]stats.NetStamp), - peakHistory: make(map[string][]float64), + winW: winW, + winH: winH, + prevCPU: make(map[string]collector.CPULine), + smoothedCPU: make(map[string]*[10]float64), + smoothedMem: make(map[string]*struct{ ramUsed, swapUsed float64 }), + smoothedNet: make(map[string]*struct{ rxPct, txPct float64 }), + prevNet: make(map[string]stats.NetStamp), + peakHistory: make(map[string][]float64), } } @@ -633,13 +637,6 @@ func printHotkeys() { fmt.Println("=> Hotkeys: 1=cores 2/m=mem 3/n=net e=extended g=avg line i=io avg s=separators h=help q=quit w=write config a/y=cpu avg d/c=net avg f/v=link scale arrows=resize") } - -// netLinkBytesPerSec returns link speed in bytes/sec from cfg.NetLink (e.g. "gbit", "10gbit", "100mbit", or numeric mbit). - -// linkScales lists the supported network link speeds in ascending order, -// used by the f/v hotkeys to cycle through link scale values. -var linkScales = []string{"mbit", "10mbit", "100mbit", "gbit", "10gbit"} - // scaleLinkUp moves cfg.NetLink to the next higher link speed in linkScales. // Clamps at the maximum (10gbit). func scaleLinkUp(cfg *config.Config) { |
