Go Get Issues

157 views
Skip to first unread message

Rich

unread,
Sep 23, 2022, 4:59:44 PM9/23/22
to golang-nuts
I have been having a really hard time with Go Get It just isn't working. We have a private Repositiory, that repository requires us to use SSH. There is no option for using https.

So, I've configured my git config "~/.gitconfig' 

```
[url "ssh://g...@internal.repository.web.mycompany.com:7999/"]
     insteadOf = https://repository.web.mycompany.com/
```
I have GOPRIVATE set
```
export GOPRIVATE="repository.web.mycompany.com"
```
Then when I use go get:
```
```

Rich

unread,
Sep 23, 2022, 7:14:45 PM9/23/22
to golang-nuts
Sorry the last line was messed up.

The error I get is:
 github.com/stretchr/testify/require: repository.web.mycompany.com/st_nsres@     v0.2.0: unrecognized import path "repository.web.mycompany.com/st_nsres":       https fetch: Get "https://repository.web.mycompany.com/st_nsres?go-get=1":      Unable to connect

It keeps trying to connect via https -- IT's SSH
Again I have ~/.gitconfig configured:
And GOPRIVATE set to repository.web.mycompany.com

Christoph Berger

unread,
Sep 25, 2022, 7:20:48 AM9/25/22
to golang-nuts
Hi Rich,

I guess, you run into the behavior described here:

> To declare the code location, an import path of the form
>    
repository.vcs/path
> specifies the given repository, with or without the .vcs suffix, using the named version control system, and then the path inside that repository.

> (...)

> If the import path is not a known code hosting site and also lacks a version control qualifier, the go tool attempts to fetch the import over https/http and looks for a <meta> tag in the document's HTML <head>.

(emphasis mine)

So it seems the go get command does not recognize the import path to be a Git repository. Otherwise it would have tried SSH, too.

I would try changing the import path to repository.web.mycompany.com/st_nsres.git to give go get a hint that the import path is a Git repo.

Rich

unread,
Sep 26, 2022, 2:39:33 PM9/26/22
to golang-nuts
After I posted this on Friday I saw about adding .git to the end, and that didn't work. Then it started saying:

Or something like that. What I had to do was delete the go.mod of repository.web.mycompany.com/st_nsres, reinitialize go mod init repository.web.mycompany.com/st_nsres.git. I then pushed that, created a tag:
git tag "v0.1.1", then git push origin "v0.1.1". 

Then in the application I built that used that package I had to go get "repository.web.mycompany.com/st_nsres.git". --THEN it started working.

When I look at the source code to go get  -- MAN the work the Go authors put into that is pretty amazing. Does anybody think it might be possible to write a go git command that might do the same things go get does but ... just for git?  In the days before go mod, I could just go into my goroot: go/src/repository.web.mycompany.com/ then do a git pull repository.web.mycompany.com/st_nsres.git. From there Go would look for it there and you wouldn't need to do a go get on it. I am not sure where it stores it today, if it were possible to somehow cache it manually like that?

Thanks for the help Christoph!!!

Christoph Berger

unread,
Sep 27, 2022, 3:47:22 AM9/27/22
to golang-nuts
You are right, when changing import paths, related info (go.mod contents in this case) need to be updated as well. This was missing from my answer, thanks for catching that.

Glad to hear that go-getting the private module works after including the VCS extension.
Reply all
Reply to author
Forward
0 new messages