I got this error that I found to be somewhat mysterious when I tried to run go test
in a module that was part of a go multi-module workspace.
> go test
directory . outside modules listed in go.work or their selected dependencies
Turned out to be a simple copy and paste error. I had copied an entire directory to make a new module and had forgotten to change the package name in the .mod file. Here’s the directory structure:
I’m really loving the workspace feature btw, if you’re doing anything serverless then it’s a much simpler build structure. I’ll try to do a post on using a workspace for a serverless project in the near future.