Imports aren't found when opening individual projects in a monorepo setup with a single go.mod file at the repo root

Answered

I have a GitHub Monorepo with three Go projects so far with more on the way. I've correctly configured the Monorepo with the `go.mod` and `go.sum` files at the root under `/repo/src` and `go build` works great on all of the individual projects. I can open the `repo/src` folder in GoLand as well and everything works great. But when I open the individual projects `/repo/src/project` - GoLand isn't finding the imports. I've verified that go modules are enabled for the individual projects settings and it doesn't help.

I've uploaded a gif to help demonstrate: Upload id: 2022_05_20_6QmG32RE57BW3Qse (file: go_modules_monorepo_issue.gif)

Any help here would be great!

0
3 comments

There is no way to use this workflow and GoLand is not able to detect that go.mod file at the top of opened proejct.

Please follow GO-9458 to support specifying the project's go.mod file.

As alternative, you can try out Go Workspaces that is introduced in 1.18 version of Go (https://go.dev/doc/tutorial/workspaces).

0

So this is purely a limitation on the GoLand side for now? Because the go compiler doesn't seem to have an issue with it.

0

Yes, it is a limitation in GoLand.

0

Please sign in to leave a comment.