Skip to content

htop-win-go

License

A minimal htop clone for Windows built with Go and tview.

Features

  • Real-time Monitoring — CPU and memory usage with visual gauges
  • Process Management — View and sort processes
  • Interactive TUI — Built with tview for responsive terminal UI
  • Sort Controls — Quick keyboard shortcuts for column sorting

Installation

powershell
cd htop\win\go
go build -o bin\htop-win-go.exe ./cmd/htop-win-go

Prerequisites

  • Go 1.21+ (1.22+ recommended)
  • Windows Terminal or PowerShell

Usage

powershell
# Run directly
go run ./cmd/htop-win-go

# Or run the built binary
.\bin\htop-win-go.exe

Keyboard Shortcuts

KeyAction
q / EscQuit
CSort by CPU%
MSort by Memory%
PSort by PID
NSort by Name

Display

  • Titlehtop-win-go
  • CPU Gauge — Visual bar with percentage
  • Memory Gauge — Visual bar with usage
  • Process Count — Number of processes

Process Table

ColumnDescription
PIDProcess ID
NAMEProcess name
CPU%CPU usage percentage
RSSResident Set Size
MEM%Memory percentage
STARTProcess start time

CPU% Calculation

CPU percentage is calculated by:

  1. Getting process CPU time (user + system)
  2. Measuring wall clock time difference
  3. Dividing by runtime.NumCPU() for total percentage

Dependencies

  • gopsutil — System and process information
  • tview — Terminal UI framework
  • tcell — Terminal handling (tview dependency)

Project Structure

htop-win-go/
├── cmd/
│   └── htop-win-go/
│       └── main.go
├── internal/
│   ├── metrics/
│   │   ├── system.go
│   │   └── processes.go
│   └── ui/
│       └── ui.go
├── changelog/
│   └── CHANGELOG.md
├── go.mod
└── Makefile

Known Limitations

  • Some system processes may fail to report information (permission denied)
  • First refresh may show 0% CPU, subsequent refreshes show accurate values
  • No process kill functionality yet

Testing

powershell
go test ./...

Comparison with Rust Implementation

FeatureGoRust
TUI Frameworktviewratatui
Sparkline history
Process kill
Search/filter
System infogopsutilsysinfo

Roadmap

  • [ ] Search/filter processes
  • [ ] Process termination
  • [ ] Adjustable refresh interval
  • [ ] Per-core CPU display
  • [ ] Disk/network metrics

License

MIT OR Apache-2.0