What Go Modules Are Used in Mole? Complete Dependency Analysis

Mole relies on five direct Go modules—Bubble Tea, Lipgloss, xxhash, gopsutil, and golang.org/x/sync—to render its terminal UI, hash metric snapshots, and collect system statistics across platforms.

Mole is a Go-based CLI system monitor developed by tw93 that combines rich terminal interfaces with real-time hardware metrics. The specific Go modules used in Mole are declared in the require block starting at line 5 of the project's go.mod file. These dependencies power everything from the interactive mo status view to the cross-platform collection of CPU, memory, and GPU statistics.

Primary Go Modules in Mole

Mole’s core functionality depends on five direct dependencies defined in go.mod. These modules handle the user interface, system metrics, caching, and concurrency orchestration.

Terminal UI Framework (bubbletea and lipgloss)

github.com/charmbracelet/bubbletea at version v1.3.10 provides the TUI (terminal UI) framework that drives the interactive mo status view. It implements the Elm architecture pattern for Go, handling user input, updates, and rendering loops.

github.com/charmbracelet/lipgloss at version v1.1.0 supplies the styling primitives used to render colored boxes, headers, and the optional ASCII cat animation. It works alongside Bubble Tea to apply margins, padding, and color profiles.

In cmd/status/main.go, these modules are imported directly to initialize the program:

import (
    tea "github.com/charmbracelet/bubbletea"
    "github.com/charmbracelet/lipgloss"
)

This import block appears at lines 13–15 of the entry point, which defines runTUIMode and the newModel() constructor used to launch the interface.

System Metrics Collection (gopsutil)

github.com/shirou/gopsutil/v4 at version v4.26.2 is the cross-platform system-information library responsible for gathering CPU, memory, disk, network, battery, and GPU statistics. It abstracts OS-specific APIs into a unified Go interface, enabling Mole to monitor hardware on Linux, macOS, and Windows without platform-specific code.

The collector implementation (typically located in the internal collector package) uses this module to populate the MetricsSnapshot struct consumed by both the UI and the JSON output mode (runJSONMode).

Caching and Concurrency (xxhash and x/sync)

github.com/cespare/xxhash/v2 at version v2.3.0 provides fast non-cryptographic hashing used by the collector for caching metric snapshots. It generates cache keys quickly without the overhead of cryptographic algorithms.

golang.org/x/sync at version v0.20.0 supplies concurrency primitives such as errgroup, which Mole uses throughout its collector pipelines to manage goroutines and aggregate errors from multiple system probes.

Indirect Dependencies

Beyond the five direct modules, Mole pulls in numerous transitive dependencies marked as // indirect in go.mod (lines 13–41). These are automatically fetched by the Go toolchain to satisfy the requirements of the primary libraries.

Key indirect modules include:

  • github.com/charmbracelet/colorprofile (v0.4.1) — Color handling for Lipgloss
  • github.com/charmbracelet/x/ansi (v0.11.4) — ANSI escape-code utilities
  • github.com/charmbracelet/x/term (v0.2.2) — Terminal size and input handling
  • github.com/muesli/termenv (v0.16.0) — Advanced terminal rendering capabilities
  • github.com/tklauser/go-sysconf (v0.3.16) — System configuration queries supporting gopsutil
  • golang.org/x/sys (v0.41.0) — Low-level OS interaction required by gopsutil

These modules form the underlying infrastructure that enables the TUI to render correctly across different terminal emulators and operating systems.

How Mole Implements These Modules

The architecture separates concerns into distinct layers: the UI layer uses Bubble Tea and Lipgloss, while the metrics layer relies on gopsutil and x/sync.

Bubble Tea Model Pattern

The following pattern mirrors the implementation in runTUIMode (lines 51–55 of cmd/status/main.go), where newModel() creates a Bubble Tea program:

package main

import (
    tea "github.com/charmbracelet/bubbletea"
    "fmt"
)

type model struct{}

func (m model) Init() tea.Cmd { return nil }
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
    switch msg := msg.(type) {
    case tea.KeyMsg:
        if msg.String() == "q" {
            return m, tea.Quit
        }
    }
    return m, nil
}
func (m model) View() string { return "Press q to quit" }

func main() {
    p := tea.NewProgram(model{})
    if _, err := p.Run(); err != nil {
        fmt.Println("error:", err)
    }
}

Gathering System Metrics with gopsutil

Mole’s collector uses the same gopsutil/v4/cpu package shown below to fill MetricsSnapshot.CPU.Usage:

package main

import (
    "fmt"
    "github.com/shirou/gopsutil/v4/cpu"
    "time"
)

func main() {
    percent, _ := cpu.Percent(time.Second, false)
    fmt.Printf("CPU usage: %.2f%%\n", percent[0])
}

Styling Headers with Lipgloss

The renderHeader function in cmd/status/view.go applies Lipgloss styles similar to this example:

package main

import (
    "github.com/charmbracelet/lipgloss"
    "fmt"
)

func main() {
    style := lipgloss.NewStyle().
        Bold(true).
        Foreground(lipgloss.Color("#FAFAFA")).
        Background(lipgloss.Color("#7D56F4")).
        Padding(0, 2)

    fmt.Println(style.Render("Mole – System Monitor"))
}

Summary

  • Mole uses five direct Go modules: Bubble Tea (v1.3.10), Lipgloss (v1.1.0), xxhash (v2.3.0), gopsutil (v4.26.2), and golang.org/x/sync (v0.20.0).
  • All dependencies are declared in the require block of go.mod starting at line 5.
  • Bubble Tea and Lipgloss power the mo status TUI implemented in cmd/status/main.go.
  • gopsutil provides cross-platform system metrics collection for CPU, memory, disk, and hardware sensors.
  • xxhash enables fast caching of metric snapshots, while x/sync manages concurrency in collector pipelines.
  • Indirect dependencies (lines 13–41 of go.mod) include terminal handling libraries like termenv and colorprofile.

Frequently Asked Questions

What is the main UI framework used in Mole?

Mole uses Bubble Tea (github.com/charmbracelet/bubbletea v1.3.10) as its primary TUI framework. It implements the Elm architecture to handle user input, state updates, and rendering in the mo status command. The styling is handled by Lipgloss (v1.1.0), which provides the color profiles and layout primitives visible in the interface.

How does Mole collect system metrics on different operating systems?

Mole delegates all system information gathering to gopsutil/v4 (v4.26.2). This module abstracts platform-specific APIs for Linux, macOS, and Windows into a single Go interface, allowing Mole to retrieve CPU usage, memory statistics, disk I/O, network interfaces, battery status, and GPU information without writing OS-specific code.

Why does Mole use xxhash for caching?

Mole imports xxhash/v2 (v2.3.0) to generate fast, non-cryptographic hash keys for caching metric snapshots. Because xxhash is optimized for speed rather than cryptographic security, it minimizes CPU overhead when the collector checks or stores cached system states between updates.

Where are all the Go modules declared in the Mole repository?

All Go modules used in Mole are declared in the go.mod file at the repository root. Direct dependencies appear in the require block starting at line 5, while transitive indirect dependencies are listed below (lines 13–41) with the // indirect comment.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →