Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using "go get" on a personal git repo [duplicate]

Tags:

git

go

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 example.com/user/package: unrecognized import path "example.com/user/package"

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

<meta name="go-import" content="example.com git http://example.com/user/package">

The actual git repository is accessible via http://example.com/user/package.git. 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 http://example.com/user/package?go-get=1 the page returned contains the META tag. If go then makes a subsequent request to http://example.com/?go-get=1 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.

like image 585
brian newman Avatar asked Oct 13 '14 19:10

brian newman


1 Answers

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="my.domain.com$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.

like image 181
Not_a_Golfer Avatar answered Sep 29 '22 11:09

Not_a_Golfer