Search code examples
gogo-modulesgopath

Why does `go mod` take up space on another disk than my GOPATH?


I'm trying to build a completely new project in order to run some unit tests. I'm using Windows + WSL.

When I try to run the tests, obviously first it takes the go.mod file and starts downloading all the packages.

Though, while my GOPATH is set on my D disk, the free space on my C disk is visibly running lower and lower. I don't understand what other process (supposedly part of building the project) can take up space on my C disk while building the project.

I also want to move everything to not depend on my C disk, as I don't have much more space left, but other than moving the GOPATH (which obviously isn't the solution here) I don't understand what I can do.

I tried building the project, the dependencies started downloading (via an automatic go mod on the go.mod file deps) and I expected them to download on the GOPATH/src, which is on disk D (verified through a number of different ways) on Windows on my machine, but it actually takes space on C.


Solution

  • GOCACHE is set to a directory on the C drive.

    Fix by running go clean -cache and then set the GOCACHE environment variable to a directory on the D drive.