go-purge is a CLI (Command Line Interface) designed to help developers clean their systems or projects by removing caches, unnecessary files, and specific directories that accumulate over time.
If you already have Go installed on your system, you can install go-purge very easily by running the following command:
go install github.com/nathan-mittelette/go-purge@latestThis command downloads and installs the latest version of go-purge on your machine in your $GOPATH/bin.
Verify the installation:
go-purge --helpYou should then see the CLI help appear in your terminal.
Here's an overview of how to use go-purge:
go-purge [global options] command [command options]For example:
-
To clean directories:
go-purge directory
-
To perform a global system cleanup:
go-purge global
go-purge provides the following commands:
-
global(aliasg):- Cleans your entire environment (Docker, Podman, Maven, Go cache, NPM caches, PNPM, Yarn, etc.).
-
directory(aliasd):- Cleans specific folders in the current directory or its subdirectories (e.g.,
node_modules,.terraform, etc.).
- Cleans specific folders in the current directory or its subdirectories (e.g.,
-
help(aliash):- Displays the list of commands or help for a specific command.
-
Global cleanup with confirmation at each step:
go-purge global
-
Global cleanup without confirmation (force mode activated):
go-purge global --force
-
Cleaning directories in the current folder:
go-purge directory
-
Cleaning directories in force mode (without confirmation):
go-purge directory --force
The global command cleans up various caches and resources from tools and technologies that developers often encounter. Here's what is currently supported:
-
Podman:
- Checks if a Podman machine is running.
- Starts the Podman machine if necessary.
- Cleans Podman with the
podman system prune --all --volumescommand.
-
Docker:
- Cleans Docker using
docker system prune --all --volumes.
- Cleans Docker using
-
Maven:
- Deletes the
~/.m2/repositoryfolder.
- Deletes the
-
Gradle:
- Deletes the cache directory located at
~/.gradle/caches.
- Deletes the cache directory located at
-
Composer:
- Deletes the Composer cache directory located at
~/.composer/cache.
- Deletes the Composer cache directory located at
-
Dart:
- Deletes the Dart cache directory located at
~/.dart_tool.
- Deletes the Dart cache directory located at
-
Pip:
- Deletes the Python cache directory.
-
Cargo:
- Deletes the Cargo cache directory located at
~/.cargo.
- Deletes the Cargo cache directory located at
-
Dotnet:
- Deletes the Dotnet cache directory.
-
SDKMAN:
- Deletes the SDKMAN cache directory.
-
Go:
- Cleans the Go cache using the command
go clean -cache -modcache -testcache.
- Cleans the Go cache using the command
-
Brew (macOS only):
- Removes unnecessary files for Homebrew.
-
NPM / Yarn / PNPM:
- Cleans the cache of JavaScript package managers (
npm,yarn,pnpm).
- Cleans the cache of JavaScript package managers (
You can execute this command with or without confirmation:
- With confirmation (default): prompts you before each action.
- Force mode (
--force): skips confirmations and performs all cleanups automatically.
The directory command focuses on cleaning specific directories in the current folder and its subfolders. The following directories are targeted for removal:
.terraform.dart_toolnode_modulestarget(used in Java or Maven projects)
This command scans your working folder for these directories and prompts you before deleting them, unless the force mode is activated.
Commands executed in the background:
find . -type d -name ".terraform" -exec rm -rf {} +
find . -type d -name ".dart_tool" -exec rm -rf {} +
find . -type d -name "node_modules" -exec rm -rf {} +
find . -type d -name "target" -exec rm -rf {} +Contributions are welcome! If you'd like to add features, fix bugs, or report issues, please don't hesitate to open an issue or a pull request on the repository.
- Fork this repository.
- Clone your fork:
git clone https://github.com/nathan-mittelette/go-purge.git
- Make your changes locally.
- Push your changes and create a pull request.
This project is licensed under the MIT License. See the LICENSE file for more information.
