Go version: 1.12.9
Here is the structure of a simple demo project:
So we have a module domain, which contains two modules: activity and person.
I would like to use domain with all nested modules in the main file => modules.go.
Ok I know how to import domain in the main go.mod:
module modules
go 1.12
replace modules/domain v0.0.0 => ./domain
require modules/domain v0.0.0
So after that can use code from domain/domain.go, but I cannot access !!! code from activity and person modules.
Yes, I could manually import nested modules, for example:
(main go.mod):
module modules
go 1.12
replace modules/domain v0.0.0 => ./domain
replace modules/domain/activity v0.0.0 => ./domain/activity
require (
modules/domain v0.0.0
modules/domain/activity v0.0.0
)
but I don't want to manually import all submodules.
Question:
How to configure modules to import domain with all submodules ???
Thanks in advance,
Hubert
but I don't want to manually import all submodules.
There is no "I want" in Go. And there is no notion of "sub"-module, all modules are equal. As are all(*) packages. If you want to use a package you must import it. Dead simple.
Best advice: Stop making every package its own module; most likely this is overkill or plain wrong. Stop making tiny packages. Stop trying to mimick a source code layout you might be used from other languages. Read "How to Write Go Code" and stick to it word for word.
(*) internal and vendored packages are an exception which does not apply to your problem.