Go workspaces

Go has a new feature in v1.18 called workspaces, which allows you to develop several different modules at the same time. A few links:

You can now create a go.work file that contains directories of local modules you are developing:

go 1.18

use ../some-module

Before Go 1.18, you could do similar things with the replace directive in the go.mod file.

I most often use this when I’m using a third party package, but don’t understand how it works or why it is doing what it is doing. You can then simply clone the package source, and tell Go to use it instead of the module in your go.mod file. Then, you can add print statements, change code, or whatever it takes to figure out the code.

This is another example of how Go is a very developer friendly programming environment – it is very easy to get done what you need to do and work with very little friction in a vast software ecosystem. There are many ways Go decreases development friction:

  • blazing fast compile times
  • high quality packages
  • easy to modify and work with 3rd party packages
  • easy to cross compile for any target (at least pure Go applications)

workspaces is another step in making all this work better.