At work we host our code on an internal gitlab site. The hostname is just “gitlab”. But if I do:
go get gitlab/jason/foo
Then I get the error: “import path does not begin with hostname”. How do I tell go that “gitlab” is the hostname? Sorry if this is a stupid question, but I can’t seem to figure this out.
So, I went straight to the source. The problem is here:
if !strings.Contains(host, ".") {
return nil, errors.New("import path does not begin with hostname")
}
So go is literally rejecting any host name without a “.” in the name. So it seems that it is impossible to “go get” a package hosted on our intranet. Anyone see a way around this restriction?
Use the fully-qualified domain name (FQDN) delivered by your intranet’s DNS server. Depending on the DNS configuration, this could be something like “gitlab.<yourcompany>.com” or “gitlab.<internalname>.lan” etc.
Use git clone instead of go get to fetch the packages.
Another option, fake it. Open up your own hosts file and add in the internal ip address pointing to fakegitlab.com and then go get fakegitlabe.com/jason/foo