Setting up a Windows Dev Drive with Go

Published 05.11.2023

Dev Drive is a new type of storage volume in Windows 11 that is specially made for programming workloads. Instead of the typical NTFS filesystem, it uses ReFS (Resilient File System), which is a newer filesystem based on Copy-on-Write (COW) linking. Basically, if you have two copies of a file, only one copy actually exists on the disk. The other one exists only as a link to the first one. Then, when you actually write to the linked file, the original data is lazily copied into it (hence Copy-on-Write). This results in much faster writes for duplicate files (or data).

Dev drive has other benefits as well. Here are some of them:

Configuring Go to use the Dev Drive #

As the official documentation states,

The Dev Drive is intended for:

Dev Drive is not intended to store developer tools, such as:

These tools should be stored on your main C:\ drive.

This means that you shouldn’t install Go itself on the Dev Drive, but tell Go to put the module cache there. There is quite a simple way to do that:

> go env -w GOPATH=D:\packages\go

Make sure to also create the D:\\packages\\go directories.

You can verify the change with go env GOPATH . It should now point to the right directory. You can also move the packages you have already installed from the previous GOPATH to the new one.

Also, don’t forget to add the new “GOBIN” location to your system path. That is where your go install’d binaries, like gopls reside. Here’s some PowerShell to do it for you:

[Environment]::SetEnvironmentVariable("Path", $env:Path + ";D:\packages\go\bin", "User")