GoLand project in a submodule directory can't find `go.mod` file in parent directory. Can a submodule GoLand project integrate with rest of module?
I have posted this in Stack Overflow as well, but I didn't get much traction there: https://stackoverflow.com/q/78674334/1436495
tl;dr: Is there a way to configure a GoLand project to recognize it is part of a larger Go module from a parent directory?
I have a small monorepo of Go code (as well as node/js/ts/vue/etc for frontend applications, but that should be irrelevant). There is a single go.mod in the repo root directory. I'm trying to create GoLand projects in various submodules of the monorepo, but it seems GoLand isn't detecting the root go.mod file. Example file structure:
root/
go.mod -- module named "mymodule"
go.sum
foo/
.idea/
main.go
bar/
.idea/
main.go
libs/
go/
mylib/
mylib.go
In the foo and bar submodules/projects, GoLand is 1) reporting 'go.mod' file is absent, 2) saying it can't resolve imports from mymodule/libs/go/mylib. Command-line go operations (building, getting, etc) are functioning and detecting the root go.mod properly.
Please sign in to leave a comment.
The only comment I got over at Stack Overflow suggested I create the GoLand project at the repo root level (which I've done before), but I'm hoping for an option to handle submodules as separate GoLand projects (specialized run configurations, project folder settings, etc) while still integrating with the rest of the module (e.g. being able to resolve other submodules).
So similar to how Jetbrains detects VCS roots in parent directories outside of the project, could GoLand detect a `go.mod` file in a parent directory?
crunk1 Hi there! Thank you for your question. I'm afraid the point from Stack Overflow is correct and there is not much we can do about it at the moment. However, I understand where this might come in handy, so raised a Feedback task describing your question. Here's the link to it on our issue tracker - https://youtrack.jetbrains.com/issue/GO-17154/Better-support-for-monorepos-find-go.mod-from-parent-directory-is-subdirectory-is-opened-in-the-IDE .
Please feel free to follow the case to get updated if there is any development in this direction.