登录
首页 >  Golang >  Go问答

在私人 gerrit 存储库中安装 golang 包

来源:stackoverflow

时间:2024-02-18 16:42:24 275浏览 收藏

最近发现不少小伙伴都对Golang很感兴趣,所以今天继续给大家介绍Golang相关的知识,本文《在私人 gerrit 存储库中安装 golang 包》主要内容涉及到等等知识点,希望能帮到你!当然如果阅读本文时存在不同想法,可以在评论中表达,但是请勿使用过激的措辞~

问题内容

我正在尝试使用 gerrit 中托管的项目之一作为 golang 中的依赖项。

  • 我在 gerrit 中安装了 go-import 插件
  • 我将其添加到 .gitconfig:
[url "ssh://[email protected]:29418"]
insteadof = https://gerrit.example.com

现在我运行:

go get gerrit.example.com/myproject

但失败了:

go get: module gerrit.example.com/myproject: git ls-remote -q origin in /home/me/go/pkg/mod/cache/vcs/513f491cb527a8cec5b684e8d77254c851f76499e1f725440f98d4e9ad8bbf4f: exit status 128:
        fatal: project a/myproject not found
        fatal: Could not read from remote repository.

正确答案


确保全局 git 配置未使用以下内容设置:

git config --global url."[email protected]:".insteadof "https://gerrit.example.com"

.gitconfig

[url "[email protected]"]
insteadof = https://gerrit.example.com

为了常规使用 git 工具,设置 ~/.ssh/config 文件会很方便。为此,请运行以下命令:

mkdir ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/config
chmod 600 ~/.ssh/config

请注意,上述文件和目录的权限对于 ssh 在大多数 linux 系统上的默认配置中工作至关重要。

然后,编辑 ~/.ssh/config 文件以匹配以下内容:

Host gerrit.example.com
  HostName gerrit.example.com
  Port 29418
  User USERNAME_HERE
  IdentityFile ~/.ssh/id_gerrit_example_com

请注意上述文件中的空格很重要,如果不正确将使文件无效。

其中 username_here 是您的 gerrit 用户名,~/.ssh/id_rsa 是文件系统中 ssh 私钥的路径。您已将其公钥上传至 gerrit

注意:我只是根据假设创建了此配置,因为我没有要测试的 gerrit 设置。

理论要掌握,实操不能落!以上关于《在私人 gerrit 存储库中安装 golang 包》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注golang学习网公众号吧!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>