I have a git repo setup on a computer on my local network (192.168.0.12). It has an entry in /etc/hosts
192.168.0.12 ubuntu-18-extssd
go get doesn't recognize my hostname (ubuntu-18-extssd
) as a host name so I use the IP address instead.
Now when I try with go get like this
go get 192.168.0.12/gitrepo/go-package-test-stringutil/stringpackage
it returns the error
package 192.168.0.12/gitrepo/go-package-test-stringutil/stringpackage: unrecognized import path "192.168.0.12/gitrepo/go-package-test-stringutil/stringpackage": https fetch: Get "https://192.168.0.12/gitrepo/go-package-test-stringutil/stringpackage?go-get=1": dial tcp 192.168.0.12:443: connect: connection refused
So I tell git to use ssh instead:
git config --global url."[email protected]:".insteadOf "https://192.168.0.12/"
and in my ~/.gitconfig I have
[url "[email protected]:"]
insteadOf = https://github.com/
[url "[email protected]:"]
insteadOf = https://192.168.0.12/
But go get still gives the same error. The entry for github works, though.
Why is the combination of go get
and git
still trying to use https when I've told it to use ssh instead?
Go cannot infer the repository type from
192.168.0.12/gitrepo/go-package-test-stringutil/stringpackage
directly, so it's trying to lookup the meta tags athttps://192.168.0.12/gitrepo/go-package-test-stringutil/stringpackage?go-get=1
:https://golang.org/cmd/go/#hdr-Remote_import_paths
If you don't want to run a server that returns the appropriate meta tags you have to let Go know that the package is in a git repository by adding
.git
to the import path. Use one of the following commands, depending on where your repository is located: