go-mod-clean

command module
v0.0.0-...-09a452c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 15 Imported by: 0

README

go-mod-clean

go-mod-clean is a cli tool to clean up unused Go modules. To be specific, it cleans up all modules within $GOPATH/pkg/mod, except for currently used modules. To specify the modules in use, you need to indicate them via go.mod files or directories that contain go.mod files. Because of the side-effect of the go module-cache, administrator privileges are required if you want to removed unused modules.

Install

go install github.com/fosmjo/go-mod-clean@latest

Usage

# show help doc
$ go-mod-clean -h
Clean up unused Go modules. To be specific, it cleans up all modules within $GOPATH/pkg/mod,
except for currently used modules. To specify the modules in use, you need to indicate them
via go.mod files or directories that contain go.mod files.

Usage:
  go-mod-clean [flags]

Flags:
  -h, --help              help for go-mod-clean
  -m, --modfile strings   go.mod files or directories that contain go.mod files,
                          modules referenced by these files are considered in use
  -v, --verbose           enable verbose mode

Use case

View unused modules
# no administrator privileges required
$ go-mod-clean -m ~/coding -m ~/work -m ~/study
Found 37 unused mods, occupied 32 MB disk space.

You can:
(1) View them.
(2) Remove them (require admistrator privileges).
(3) Quit.

Type one of the numbers in parentheses:1
Remove unused modules
# require administrator privileges
$ sudo -E go-mod-clean -m ~/coding -m ~/work -m ~/study
Found 37 unused mods, occupied 32 MB disk space.

You can:
(1) View them.
(2) Remove them (require admistrator privileges).
(3) Quit.

Type one of the numbers in parentheses:2

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL