Skip to content

Alvalens/goweep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoWeep — Developer's Disk Space Recovery Tool

goweep is a high-performance, parallel CLI utility written in Go. It is designed to quickly identify and remove common development "junk" folders (like node_modules, .venv, target, and dist) to reclaim disk space across large workspaces.

Built with a "safety-first" philosophy, it features a mandatory dry-run mode and interactive confirmation prompts to prevent accidental data loss.

Features

  • High-Speed Parallel Scanning: Utilizes a worker pool and Go's concurrency primitives to measure directory sizes in parallel.
  • Intelligent Discovery: Automatically skips sub-directories of matched folders (e.g., prevents scanning nested node_modules inside a pnpm tree) for maximum efficiency.
  • Impactful Reporting: Sorts findings by size (heaviest first) and summarizes the Top 10 cleanup targets to reduce output noise.
  • Smart Filtering: Supports age-based filtering (e.g., "only delete folders older than 30 days").
  • Safe by Default: Dry-run mode is active by default. No deletion occurs without explicit --dry-run=false and user confirmation.
  • Professional CLI: Clean, color-coded output with status prefixes ([OK], [ERROR], [DRY-RUN]).

Installation

Since the tool is written in Go, it compiles to a single static binary with no external dependencies.

  1. Clone the repository:

    git clone https://github.com/yourusername/goweep.git
    cd goweep
  2. Build the binary:

    go build -o goweep.exe
  3. Run it:

    ./goweep.exe --path .

Usage

There are two ways to run GoWeep: during development using the Go compiler, or using the standalone executable.

1. Running from Source (Development)

Useful when you are testing changes or don't want to build a binary yet.

# Basic scan
go run main.go --path .

# Deep clean with custom targets
go run main.go --path "C:\Projects" --targets "node_modules,dist,build" --dry-run=false

2. Running the Executable (Production)

The preferred way to use GoWeep as a regular tool.

# Basic scan (Dry-run)
./goweep.exe --path .

# Delete folders older than 30 days
./goweep.exe --path "Z:\Projects" --older-than 30 --dry-run=false

# Automation mode (No confirmation prompt)
./goweep.exe --path "C:\Temp" --dry-run=false --force

3. Advanced Variations

  • Custom Worker Count: Increase speed on high-core CPUs (default is 4).
    goweep --path . --workers 16
  • Target Specific Ecosystems: Focus only on Python environments.
    goweep --targets ".venv,venv,__pycache__" --dry-run=false
  • Clean Entire Workspace: Scan a parent directory to find all nested junk.
    goweep --path "Z:\Workspaces" --dry-run=false

Default Targets

The tool tracks the following patterns by default:

  • Node.js: node_modules
  • Python: .venv, venv, env, __pycache__
  • Rust/Java: target
  • Web: dist, build, .next, .nuxt, .cache
  • Go: vendor
  • Mobile: Pods, bower_components

Development

Running Tests

Ensure logic and size calculations remain accurate.

go test ./...

Architecture

  • /scanner: Parallel filesystem walking, size calculation, and discovery optimization.
  • /deleter: Safe execution logic, confirmation prompts, and error handling.
  • /output: Result aggregation (sorting/limiting) and terminal formatting.

Why Go?

This utility leverages Go's Goroutines and Channels to manage disk I/O efficiently, allowing the tool to stay responsive even when scanning millions of files. The resulting static binary makes it portable across Windows, macOS, and Linux with zero setup.


🎓 Learning Journey

This was my first project exploring the Go programming language! Coming from a Node.js and Python background, this project was a hands-on way to learn:

  • Parallelism vs Concurrency: Implementing a worker-pool pattern using go routines and buffered channels.
  • Explicit Memory: Understanding the use of pointers (*) and references (&) for efficient data handling.
  • Strict Typing: Moving from dynamic languages to Go's safe and predictable type system.
  • Software Architecture: Organizing code into modular packages (scanner, deleter, output) to keep the codebase maintainable.
  • The Go Ecosystem: Using go mod, go test, and the standard library to build a production-ready tool with minimal external dependencies.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages