I have created repositories under multiple subdirectories on a private GitLab that contain Go language packages.
The hierarchy of the repository is below.
https://mygitlab.example.com/grand-parent-org/parent-org/child-org/myrepository.git
Also, the hierarchy of the library is below.
https://mygitlab.example.com/grand-parent-org/parent-org/child-org/myrepository/golib/go.mod
In this situation, I had initially assumed the package name as mygitlab.example.com/grand-parent-org/parent-org/child-org/myrepository/golib
on go.mod in library, but could not successfully go get.
I tried the command.
go get mygitlab.example.com/grand-parent-org/parent-org/child-org/myrepository/golib
When executed, it will search for mygitlab.example.com/grand-parent-org.git
and mygitlab.example.com/grand-parent-org/parent-org.git
as repositories, but will not search deeper hierarchies as repositories by go get.
After various studies, we found that the library side go.mod, etc. can be used stably by setting it to mygitlab.example.com/grand-parent-org/parent-org/child-org/myrepository.git/golib
When go get is done or as import of source code to use the library, it is written as follows.
import "mygitlab.example.com/grand-parent-org/parent-org/child-org/myrepository.git/golib"
In GitLab, unauthenticated https access does not get to see deeper than the top-level group.
Either don't use subgroups (GitHub work pretty well without) or use authentication.
For the latter, read “Passing credentials to private repositories”.