go - 无法导入私有(private) gitlab 存储库

标签 go gitlab go-get

这个问题在这里已经有了答案:





What's the proper way to "go get" a private repository?

(17 个回答)


2年前关闭。




我正在尝试将私有(private) gitlab 存储库导入到我的 Go 代码中。
我想使用用户访问 token 进行身份验证。有没有一种方法可以在导入命令中传递访问 token 。

我尝试在 import 命令中使用基本的 oauth2 url,但 import 命令只接受一个路径。

最佳答案

你可以运行命令

git config --global url.git@gitlab.com:.insteadOf https://gitlab.com/

再试一次,它会使用你的 git 凭证与 gitlab 一起工作。

例如,您的存储库位于 https://gitlab.com/yourname/hello

你跑
go get gitlab.com/yourname/hello

关于go - 无法导入私有(private) gitlab 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58724470/

相关文章:

go - 如何重定向到另一个网页

arrays - 从两个 slice 的重复项创建一个 slice

go - redigo 是否重新连接到服务器?

jenkins - 将项目从 gitlab 存储库克隆到 Jenkins 时出现问题?

在获取主要版本模块依赖项时出错

在同一文件夹中导入 go 文件

git - 如何确定 git 提交是否跳过了 pre-hook 检查?

git - 无法推送到 gitlab 中的新项目 - 提交消息不遵循模式

去模组 : not able to retrieve submodules for private repo

git - go get无法使用不可路由的IP地址