Reputation: 31
I have set up git repo on my own server and can deal with it via ssh, something like that (I use ssh key for it)
git clone [email protected]:/home/git/repo.git
and I have set up git daemon, so I can use it something like following
git clone [email protected]:/home/git/repo
I have configured local git to use ssh instead of https, so my ~/.gitconfig has following
[url "[email protected]:"]
insteadOf = https://myserver.com
and following works well
git clone https://myserver.com/home/git/repo
but when I try to deal with it by 'go get'
go get myserver.com/home/git/repo
I got an error
go get: unrecognized import path "myserver.com/home/git/repo": https fetch: Get "https://myserver.com/home/git/repo?go-get=1": dial tcp HERE_IS_IP_ADDR:443: connect: connection refused
I have already tried to do something like that
go env -w GOPRIVATE="myserver.com/home/git/repo"
but it doesn't work.
I use go version go1.16.4 linux/amd64
Could somebody help with it?
Upvotes: 3
Views: 1854
Reputation: 52226
When you designate your repo as an import path to go, try adding .git
to the chunk that represents the root of the target repository :
go get myserver.com/home/git/repo.git
# to get a subpackage:
go get myserver.com/home/git/repo.git/sub/pkg
go help get
has the following paragraph :
For more about how 'go get' finds source code to download, see 'go help importpath'.
go help importpath
explains, in the Remote import paths
section :
a few hosting platforms, like github.com
or bitbucket.org
, are automatically handled ; for other hosting solutions :
To declare the code location, an import path of the form
repository.vcs/path
specifies the given repository, ...
where .vcs
can be one of .git, .hg, .svn, .bzr, .fossil
.
Upvotes: 3