Create a new directory for your project.
Inside the directory git clone
your projects.
Next, from within the project directory (where the individual projects are cloned within), create your go.work
file.
You can do this in one of two ways:
go work init ./cli ./go-fastly
or
go work init
go work use ./cli ./go-fastly
The latter is useful for changing the work file after you've started working.
You should end up with a file tree that looks something like this:
.
├── cli
│ ├── go.mod
├── go-fastly
│ ├── go.mod
├── go.work
├── go.work.sum
Now when you cd
into one of the project directories (e.g. cd ./cli
), and go run
the code, you'll find it auto-magically identifies the dependency (e.g. ./go-fastly
) and uses that instead of trying to pull the remote/real dependency.
Warning
This causes gopls in Neovim to report an error (although the LSP still works).
LSP[gopls]: Error SERVER_REQUEST_HANDLER_ERROR "... ENOENT: no such file or directory"