What I essentially have is a mono-repo, which doesn't have a go.mod
at the root level. There are multiple directories inside this mono-repo, with each of them having their own go.mod
files. I'll refer to them as sub-modules
.
Now, I've figured out a way to be able to access the sub-modules independently (versioned) in a completely different codebase. The issue I'm facing now is, to dis-allow the import of the entire mono-repo, using:
go get link.to/mono-repo@commit_id
------> A
and only allow import using :
go get link.to/mono-repo/sub_mod1@v0.x.y
go get link.to/mono-repo/sub_mod2@v0.y.z
The command A
is able to fetch the entire repo, and then can be used to access the inner modules. Is there any way to stop this from being allowed?
I tried a few things, like:
- Added non-compilable code in a file
noCompile.go
at the root level. Ongo get...
, the compilation error is printed, but use of the inner modules still works fine. - Added an
init()
function in the samenoCompile.go
file, which just callspanic()
. This init function is not being executed, as the root directory is never directly accessed, only the inner modules are.
Is there ANY way to achieve what I'm intending to?