What is go clean -modcache?

Overview

The go ​clean -modcache is a command that is run on the terminal on computers where go is installed. This command deletes the cache downloaded along with unpacked code dependencies. These packages can be found in the $GOPATH/pkg/mod directory.

When is this command used?

This command is used when we want to remove our downloaded packages. It lets us download packages for reading an excel file; when we run the code. It removes the package.

Why is it used?

There are times when we want to do a major upgrade to the application, and at times we want to remove all downloaded packages.

Another reason is that we might encounter serious errors while developing our application after installing a package. So most times, it is best to run the code to clean.

How the command works

how go clean -modcache works

New on Educative
Learn any Language for FREE all September 🎉
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources