Golang unable to download private dependencies

722 Views Asked by At

My project have some dependencies on my companies private gitlab repository. They are basically sub modules.

Structure is like as below

code.company.com/project/modules/

module1 - git repository
module2 - git repository
module2 - git repository

I have configured SSH on gitlab and able to clone module1,2 and 3 on my system.

I have configured go env

GOPRIVATE=code.company.com/*
GOPROXY=https://proxy.golang.org,direct

I have configured git configuration as below

[url "ssh://[email protected]:"]
    insteadOf = https://code.company.com/

Now, some modules are dependent on each other. So, I have dependency as below.

module code.company.com/project/modules/module1

go 1.17

require (
    code.company.com/project/modules/module2 v0.1.0
    code.company.com/project/modules/module3 v0.1.0
)

But, when I do go build, I am getting below issue.

somepackage\somefile.go:9:2: reading code.company.com/project/modules/module2/module2/go.mod at revision module/v0.1.0: git ls-remote -q origin in C:\***\go\pkg\mod\cache\vcs\640f608ba2ce74aefee0ca7a10bdb3bc54095ae8d5ba700aeb3a063cdf50a7a6: exit status 128:
        ssh: Could not resolve hostname code.company.com:project: Name or service not known
        fatal: Could not read from remote repository.

        Please make sure you have the correct access rights
        and the repository exists.

I tried everything but unable to download repository. I am getting same issue. Please let me know if I am missing something here.

Thanks

0

There are 0 best solutions below