brian newman brian newman - 2 years ago 104
Git Question

Using "go get" on a personal git repo

I host my git repositories on a personal VPS and I have one package that I want to make "go get"-able. I have tried to set everything up per the help document found by issuing "go help importpath" with no luck. No matter what I do I get the following error:

package unrecognized import path ""

I've tried every combination of the mentioned META tag with the same results.

<meta name="go-import" content=" git">

The actual git repository is accessible via I am able to clone it directly but I want go to download and install it properly.

Per the help document, if go makes a request to the page returned contains the META tag. If go then makes a subsequent request to the page returned also contains the exact same META tag.

Does any special configuration need to be done on the server? I wouldn't think so since go would be accessing the repository via an http request.

I'm at my wits end. Any help you can provide would be greatly appreciated.

Answer Source

This is the meta tag I've configured nginx to return for a gitlab server: if you request http://mygit.server/group/project?go-get=1

you get:

<meta content='mygit.server/group/project git git+ssh://[email protected]/group/project.git' name='go-import'>

And it works like a charm.

Here is the nginx rewrite rule that does this:

location ~ "(/[^/]+/[^/]+)(/.*)?" {
    if ($arg_go-get = "1") {
            echo '<html><head><meta name="go-import" content="$1 git git+ssh://[email protected]$1"/></head></html>';
    try_files $uri $uri/index.html $uri.html @gitlab;

This of course assumes you're working with git over ssh. If you're using https rewrite the url accordingly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download