-
Book Overview & Buying
-
Table Of Contents
Go Recipes for Developers
By :
Sometimes you need to work with multiple interdependent modules. A convenient way to do this is by defining a workspace. A workspace is simply a set of modules. If one of the modules within a workspace refers to a package in another module in the same workspace, it is resolved locally instead of that module being downloaded over the network.
$ cd ~/projects $ mkdir ws $ cd ws
$ go work init
This will create a go.work file in this directory.
Let’s demonstrate this using our example. Let’s say we have the following directory structure:
$HOME/ projects/ ws/ go.work webform sqlite
Now, we want to add the two modules, webform and sqlite, to the workspace. To do that, use this:
$ go work use ./webform $ go work use ./sqlite
These commands will add the two modules to your workspace. Any sqlite reference from the webform module will now be resolved to use the local copy of the module.