"go get" and intranet-hosted repo

Hi,

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.

Thanks
Jason

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?

Two options come to mind:

  1. 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.

  2. Use git clone instead of go get to fetch the packages.

Aha, yes, that works. Thank you for your help!

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

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.