In a typical enterprise application project, it is common to split the code into several repositories, especially if the architecture used is microservice architecture. In more specific cases where the communication between components are using gRPC, there are generated gRPC client that usually invoked from another repo. Or there are core/common modules that should be reused from all repositories instead of duplicating.

In these cases, importing modules from another repo becomes a necessity. In an enterprise, the source code won’t be published on a public repository, but instead in a private repository, most likely with Github enterprise

Your code may then import package from another private repository like this:
import(
grpcClient "github.azc.ext.mycompany.com/myapp/price-service/grpc"
)

The most common problem is to have this error when you try to build

go: github.azc.ext.mycompany.com/myapp/[email protected]: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/fb3f4a78c344346ca1c63eb8160c9dd22cd33fe6a1c9a971c7487bd099500f29: exit status 128:
--
36 | fatal: could not read Username for 'https://github.azc.ext.mycompany.com': terminal prompts disabled

This is because go will try to import packages from a private Github repo, which requires authentication.

The solution is to configure git to use an authentication whenever calling the private repo

git config --global url.https://[email protected]/.insteadOf https://github.azc.ext.mycompany.com/

MY_TOKEN_HASH should be replaced with your own personal Github access token. To generate it, follow the steps here
https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token

Another command to execute is to set the GOPRIVATE environment variable. The GOPRIVATE environment variable controls which modules the go command considers to be private (not available publicly) and should therefore not use the proxy or checksum database
go env -w GOPRIVATE="github.azc.ext.mycompany.com"