使用“去获取”在个人git回购 [英] Using "go get" on a personal git repo

查看:107
本文介绍了使用“去获取”在个人git回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的git存储库托管在个人VPS上,并且我有一个我想要去获取的包。我试图根据通过发布go help importpath找到的帮助文档设置所有内容,但没有运气。无论我做什么,我都会收到以下错误:

  package example.com/user/package:无法识别的导入路径示例。 com / user / package

我已经尝试了提到的META标签的每个组合, 。

 < meta name =go-importcontent =example.com git http://example.com/user /包> 

实际的git存储库可以通过 http://example.com/user/package.git 。我可以直接克隆它,但我想要下载并正确安装它。



根据帮助文档,如果go请求 http://example.com/user/package?go-get=1 返回的页面包含META标签。如果去,然后请求 http://example.com/?go-get=1返回的页面也包含完全相同的META标签。



是否需要在服务器上完成任何特殊配置?我不这么认为,因为go会通过http请求访问版本库。



我很聪明。任何帮助,您可以提供将不胜感激。

解决方案

这是元标记我配置nginx返回一个gitlab服务器:
如果您请求 http://mygit.server/group/project?go-get = 1



你得到:

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

它就像一个魅力一样。

这是nginx重写规则:

  location〜(/ [^ /] + / [^ /] +)(/.*)? {
if($ arg_go-get =1){
echo'< html>< head>< meta name =go-importcontent =my.domain.com $ 1 git git + ssh://git@my.domain.com$1/>< / head>< / html>';
}
try_files $ uri $ uri / index.html $ uri.html @gitlab;
}

这当然假设你正在使用git over ssh。如果您使用https,请相应地重写URL。


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.

解决方案

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://git@mygit.server/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://git@my.domain.com$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.

这篇关于使用“去获取”在个人git回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆