0

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://git@code.company.com:"]
    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

Ashish
  • 39
  • 1
  • 1
    Something is probably **not** setup correctly so that you endup with this **hostname**: `code.company.com:project:`.... which leads to a DNS failure, of course: `ssh: Could not resolve hostname code.company.com:project: Name or service not known` – eftshift0 Sep 20 '22 at 11:45
  • This url looks fishy: `ssh://git@code.company.com:` (because of the closing colon). I guess it should be `ssh://git@code.company.com`. – eftshift0 Sep 20 '22 at 11:47
  • If I setup url to "ssh://git@code.company.com" then getting this issue. ssh: Could not resolve hostname code.company.comproject: Name or service not known – Ashish Sep 20 '22 at 11:51
  • Where does `project` come from? Maybe the problem is there. Perhaps it should be `/project` wherever it is setup?... I am in the blind, by the way. No experience with golang... just making.... _educated(?) guesses_. – eftshift0 Sep 20 '22 at 11:52
  • If I remove url configuration from gitconfig, then I am getting this issue fatal: repository 'https://code.company.com/project/modules.git/' not found but modules is not a git project. I don't know how this .git is keep on adding. – Ashish Sep 20 '22 at 11:54
  • https://stackoverflow.com/questions/58305567/how-to-set-goprivate-environment-variable – gipsy Sep 20 '22 at 13:14

0 Answers0