I am using BorgBackup to backup my entire home, exluding some folders (cache, node_modules, etc).
I want to have a backup of all my code (even though I keep it on github and my private Gogs instance), so I didn’t want to exclude the entire GOPATH, but because of all the installed third-party dependencies, it grew pretty big in size.


Multiple GOPATH entries.

You can use multiple directories as your GOPATH.

$ go env GOPATH

The way this works, go get defaults to the first directory (so, ~/.local/share/go), so the third-party code lands there, and for my personal projects, I can manually create the directories in ~/code/go. Go import statements check both directories.

This way I can put ~/.local/share/go in my exclusion list and not waste space by backing up the third-party code.