Defining multiple modules within a project
The Go module system is designed to manage dependencies and versions for the entire module, not for subsets or subprojects within a module. However, there might be situations where you have multiple distinct components or subprojects within your main project, and each of these components or subprojects has dependencies and version requirements. In such cases, you can structure your project in a way that each component is its own module, separate from the main project module. These submodules can be maintained as separate Go modules, each with its own go.mod
file.
For example, if you have a project with a main component and two other components, and each component has unique dependencies, you can structure your project like this:
myproject/ ├── mainmodule/ │ ├── main.go │ ├── go.mod │ ├─...