1

In our local network, we have a GitLab running. The IP is bind to gitlab.local. I have a go package http://gitlab.local/projectsmall/core, and it is being used by another Go project. Inside this project, when I try to run go mod tidy, I am getting this error:

go get gitlab.local/projectsmall/core: 
unrecognized import path "gitlab.local/projectsmall/core" 
(https fetch: 
  Get https://gitlab.local/projectsmall/core?go-get=1: 
  dial tcp 192.168.28.9:443: 
  connect: connection refused
)

I have added the id_rsa.pub contents to SSH Kyes. I tried to add this core project to go mod path like this: /Users/UserA/go/pkg/mod/gitlab.local/guxin/core. The import "gitlab.local/guxin/core" is still red using GoLand IDE. It seems the go mod project can't find this gitlab.local/guxin/core package. In go.mod file, inside require block, when I added this gitlab.local/guxin/core, the IDE alert: usage: require module/path.

P Varga
  • 19,174
  • 12
  • 70
  • 108
yong ho
  • 3,892
  • 9
  • 40
  • 81
  • although `go get` do not work well with gitlab, but at first you might need to solve the `connection refused` issue – zzn Apr 30 '19 at 08:18
  • The first thing to do is getting `curl -v https://gitlab.local/projectsmall/core?go-get=1` to work. This seems to be a networking, connectivity issue unrelated to Go. – Volker Apr 30 '19 at 08:45

2 Answers2

1

I found out it is using https, but local gitlab is not using SSL. So I tried go get -v -insecure and it's working now.

yong ho
  • 3,892
  • 9
  • 40
  • 81
-1

I'm not sure, but it seems to me that the problem may be that you are using the ssh keys and you are connecting via the HTTPs protocol as you can see from the error text.

Try it: https://gist.github.com/dmitshur/6927554

$ ssh -A vm
$ git config --global url."git@gitlab.local:".insteadOf "https://gitlab.local/"
$ cat ~/.gitconfig
[url "git@gitlab.local:"]
    insteadOf = https://gitlab.local/
$ go get gitlab.local/private/repo && echo Success!
Success!

And also: What's the proper way to "go get" a private repository?

In GitLab, since the repositories always end in .git, I must specify .git at the end of the repository name to make it work, for example:

import "example.org/myuser/mygorepo.git"

And:

$ go get example.org/myuser/mygorepo.git

Looks like GitHub solves this by appending ".git".

Magestro
  • 34
  • 5
  • If you believe there is a solution at one of those links, include the relevant details in the body of your answer. Links can die over time and this answer would become useless to someone searching for it in the future. – Adrian Apr 30 '19 at 13:46