go get获取gitlab私有仓库的代码

栏目: 编程工具 · 发布时间: 5年前

内容简介:[toc]在上一篇文章中,已经介绍了如何搭建Gitlab Https服务<在

目录

[toc]

1、Gitlab的搭建

在上一篇文章中,已经介绍了如何搭建Gitlab Https服务< Nginx设置Https反向代理,指向Docker Gitlab11.3.9 Https服务 >

2、如何通过go get,获取Gitlab的代码

$GOROOT/src/cmd/go/internal/get/vcs.go 的源码中可以看到,大概在997行左右 , go get 还是使用 GIT 获取代码的。

// vcsPaths defines the meaning of import paths referring to
// commonly-used VCS hosting sites (github.com/user/dir)
// and import paths referring to a fully-qualified importPath
// containing a VCS type (foo.com/repo.git/dir)
var vcsPaths = []*vcsPath{
    // Github
    {
        prefix: "github.com/",
        re:     `^(?P<root>github\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[\p{L}0-9_.\-]+)*$`,
        vcs:    "git",
        repo:   "https://{root}",
        check:  noVCSSuffix,
    },

    // Bitbucket
    {
        prefix: "bitbucket.org/",
        re:     `^(?P<root>bitbucket\.org/(?P<bitname>[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$`,
        repo:   "https://{root}",
        check:  bitbucketVCS,
    },

    // IBM DevOps Services (JazzHub)
    {
        prefix: "hub.jazz.net/git/",
        re:     `^(?P<root>hub\.jazz\.net/git/[a-z0-9]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`,
        vcs:    "git",
        repo:   "https://{root}",
        check:  noVCSSuffix,
    },

    // Git at Apache
    {
        prefix: "git.apache.org/",
        re:     `^(?P<root>git\.apache\.org/[a-z0-9_.\-]+\.git)(/[A-Za-z0-9_.\-]+)*$`,
        vcs:    "git",
        repo:   "https://{root}",
    },

    // Git at OpenStack
    {
        prefix: "git.openstack.org/",
        re:     `^(?P<root>git\.openstack\.org/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(\.git)?(/[A-Za-z0-9_.\-]+)*$`,
        vcs:    "git",
        repo:   "https://{root}",
    },

    // chiselapp.com for fossil
    {
        prefix: "chiselapp.com/",
        re:     `^(?P<root>chiselapp\.com/user/[A-Za-z0-9]+/repository/[A-Za-z0-9_.\-]+)$`,
        vcs:    "fossil",
        repo:   "https://{root}",
    },

    // General syntax for any server.
    // Must be last.
    {
        re:   `^(?P<root>(?P<repo>([a-z0-9.\-]+\.)+[a-z0-9.\-]+(:[0-9]+)?(/~?[A-Za-z0-9_.\-]+)+?)\.(?P<vcs>bzr|fossil|git|hg|svn))(/~?[A-Za-z0-9_.\-]+)*$`,
        ping: true,
    },
}

如果是 http 服务,可以通过使用 -insecure 选项获取:

> go get -insecure  mygitlab.com/user/repo

但每次要输入密码比较麻烦,不过 go 提供了https->ssh的映射,执行如下命令即可,其中 lion 是你的帐号:

> git config --global url."git@gitlab-ce.mshk.top:".insteadOf "https://lion@gitlab-ce.mshk.top/"

配置好的文件在 ~/.gitconfig 文件中,执行 cat ~/.gitconfig 可以 看到以下内容:

[url "git@gitlab-ce.mshk.too:"]
    insteadOf = https://lion@gitlab-ce.mshk.top/

获取后的效果如下:

go get获取gitlab私有仓库的代码

博文作者:迦壹

博客地址: go get获取gitlab私有仓库的代码

转载声明:可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明,谢谢合作!

比特币地址:1KdgydfKMcFVpicj5w4vyn3T88dwjBst6Y

以太坊地址:0xbB0a92d634D7b9Ac69079ed0e521CC2e0a97c420


以上所述就是小编给大家介绍的《go get获取gitlab私有仓库的代码》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

计算机网络(第7版)

计算机网络(第7版)

谢希仁 / 电子工业出版社 / 2017-1 / 45.00

本书自1989年首次出版以来,曾于1994年、1999年、2003年、2008年和2013年分别出了修订版。在2006年本书通过了教育部的评审,被纳入普通高等教育“十一五”国家级规划教材;2008年出版的第5版获得了教育部2009年精品教材称号。2013年出版的第6版是“十二五”普通高等教育本科国家级规划教材。 目前2017年发行的第7版又在第6版的基础上进行了一些修订。 全书分为9章,比较......一起来看看 《计算机网络(第7版)》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

URL 编码/解码
URL 编码/解码

URL 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具