“去得到"的正确方法是什么?私人仓库? [英] What's the proper way to "go get" a private repository?

查看:31
本文介绍了“去得到"的正确方法是什么?私人仓库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过多次谷歌尝试后,我正在寻找让 $ go get 使用私有存储库的方法.

I'm searching for the way to get $ go get work with private repository, after many google try.

第一次尝试:

$ go get -v gitlab.com/secmask/awserver-go
Fetching https://gitlab.com/secmask/awserver-go?go-get=1
https fetch failed.
Fetching http://gitlab.com/secmask/awserver-go?go-get=1
Parsing meta tags from http://gitlab.com/secmask/awserver-go?go-get=1 (status code 200)
import "gitlab.com/secmask/awserver-go": parse http://gitlab.com/secmask/awserver-go?go-get=1: no go-import meta tags
package gitlab.com/secmask/awserver-go: unrecognized import path "gitlab.com/secmask/awserver-go

是的,它没有看到元标记,因为我不知道如何提供登录信息.

Yep, it did not see the meta tags because I could not know how to provide login information.

第二次尝试:

关注https://gist.github.com/shurcooL/6927554.将配置添加到 .gitconfig.

Follow https://gist.github.com/shurcooL/6927554. Add config to .gitconfig.

[url "ssh://git@gitlab.com/"]
    insteadOf = https://gitlab.com/
$ go get -v gitlab.com/secmask/awserver-go --> not work
$ go get -v gitlab.com/secmask/awserver-go.git --> work but I got src/gitlab.com/secmask/awserer-go.git

是的,它可以工作,但是使用带有我的项目名称的 .git 扩展名,我可以将其重命名为原始文件,但是每次 $ go get 不太好时都这样做,是吗另一种方式?

Yes it work but with .git extension with my project name, I can rename it to original but do it everytime $ go get is not so good, is there an otherway?

推荐答案

您需要配置一件事.该示例基于 GitHub,但这不应改变流程:

You have one thing to configure. The example is based on GitHub but this shouldn't change the process:

$ git config --global url.git@github.com:.insteadOf https://github.com/
$ cat ~/.gitconfig
[url "git@github.com:"]
    insteadOf = https://github.com/
$ go get github.com/private/repo

为了让 Go 模块工作(使用 Go 1.11 或更新版本),您还需要设置 GOPRIVATE 变量,以避免使用公共服务器来获取代码:

For Go modules to work (with Go 1.11 or newer), you'll also need to set the GOPRIVATE variable, to avoid using the public servers to fetch the code:

export GOPRIVATE=github.com/private/repo

这篇关于“去得到"的正确方法是什么?私人仓库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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