Looking for a bit of help. I have a private repo hosted on a remote gitlab instance that I SHOULD be able to access. But no matter what I try, go get
seems to be trying to use https instead of SSH. I can git clone
, git fetch
, etc
without any issue. But as soon as I use go get
, it fails.
First thing I did was add this:
git config --global --add url."git@git.mydomain.io:".insteadOf "https://git.mydomain.io/"
Then I cd to my project directory and run a go get and it fails trying to authenticate over HTTPS with a "fatal: could not read Username for 'https://git.my.domain': terminal prompts disabled":
PS C:\Users\User\go\src\git.my.domain\ps\wk\collector> go get
go: downloading git.my.domain/ps/mqtt v0.0.0-20220903204713-6f195510d46e
go: git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: verifying module: git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: reading https://sum.golang.orglookup/git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: 404 Not Found
server response:
not found: git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/v
cs/3a728c5d3b6137ea441372540f3e7bc1390c001346a70d5b7df3eda6d5e7316d: exit status 128:
fatal: could not read Username for 'https://git.my.domain': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
go: git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: verifying module: git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: reading https://sum.golang.org/lookup/git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: 404 Not Found
server response:
not found: git.my.domain/ps/mqtt@v0.0.0-20220903204713-6f195510d46e: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/v
cs/3a728c5d3b6137ea441372540f3e7bc1390c001346a70d5b7df3eda6d5e7316d: exit status 128:
fatal: could not read Username for 'https://git.my.domain': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
go: module git.my.domain/ps/wk/collector/service: git ls-remote -q origin in C:\Users\User\go\pkg\mod\cache\vcs\7d02e96755cff57eaec3323ab70c24a12ab19
eac805790ed1220d62b15affcf8: exit status 128:
remote:
remote: ========================================================================
remote:
remote: The project you were looking for could not be found.
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
go: module git.my.domain/ps/wk/collector/service/service: git ls-remote -q origin in C:\Users\User\go\pkg\mod\cache\vcs\7d02e96755cff57eaec3323ab70c2
4a12ab19eac805790ed1220d62b15affcf8: exit status 128:
remote:
remote: ========================================================================
remote:
remote: The project you were looking for could not be found.
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I'm going absolutely nuts. I've tried every combination of getting go get
to use SSH:
git config --global --add url."git@git.mydomain.io/".insteadOf "https://git.mydomain.io/"
git config --global --add url."git@git.mydomain.io".insteadOf "https://git.mydomain.io"
git config --global --add url."ssh://git@git.mydomain.io:".insteadOf "https://git.mydomain.io/"
...
Is there something special I have to do somewhere? I just don't understand why go get
is using HTTPS while git commands appear to be correctly using SSH..
======================
EDIT: Ok more expirementing got me to realize that this IS working:
[url "ssh://git@git.mydomain.io"] insteadOf = https://git.mydomain.io/
because I get a new error:
ssh: Could not resolve hostname git.mydomain.iops: Name or service not known
fatal: Could not read from remote repository.
But as soon as I add that trailing slash to fix it, I get back to HTTPS errors. Is there something going on HTTPS wise that happens before ssh?