

go get 安装gitlab私有包
source link: https://studygolang.com/articles/35397
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

go get 安装gitlab私有包
hickey666 · 3天之前 · 153 次点击 · 预计阅读时间 1 分钟 · 大约8小时之前 开始浏览获取gitlab的token
进入Gitlab—>Settings—>Access Tokens,然后创建一个personal access token,这里权限最好选择只读(read_repository)。
git配置添加access token
有了access token后,我们还需要在git中进行配置,这样才能go get下了私有仓库的包,需要把刚刚的token添加进git的请求头中,操作如下:
git config --global http.extraheader "PRIVATE-TOKEN: YOUR_PRIVATE_TOKEN"
- 配置git将请求从ssh转换为http
git config --global url."git@gitlab_url:groupName/projectName.git".insteadOf "https://gitlab_url/groupName/projectName.git"`
上面是通过命令修改配置,也可以像这样,直接修改配置文件 ~/.gitconfig,在里面添加如下配置:
[url "git@{{gitlab_url}}:"]
insteadOf = https://{{gitlab_url}}/
注意:insteadof 中的参数是https,因为不管目标地址是http还是https,go get默认使用https方式访问,因此我们要强制将https转换成git协议
- 如果这样还拉不下来,就需要对go的一些环境变量进行配置
Bash (Liunx or macOS)
# 配置 GOPROXY 环境变量
export GOPROXY=https://goproxy.io,direct
# 还可以设置不走 proxy 的私有仓库或组,多个用逗号相隔(可选)
export GOPRIVATE=git.mycompany.com,github.com/my/private
Powerbash (Windows)
# 配置 GOPROXY 环境变量
$env:GOPROXY = "https://goproxy.io,direct"
# 还可以设置不走 proxy 的私有仓库或组,多个用逗号相隔(可选)
$env:GOPRIVATE = "git.mycompany.com,github.com/my/private"
Recommend
-
80
环境准备系统:CentOS6.7内存:建议4G以上。安装所需软件包:yuminstallpatchgitwget-y1.下载所需软件包到根目录下这里使用rpm包方式安装,我们使用的软件包版本为:gitlab-ce-9.1.2wgethttps://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-9.1.2-c...
-
78
本来以为配置了上篇操作就可以高枕无忧了,没想到,在引用的项目中,出现路径找不到的情况 cannot find module providing package go-sdk/wxsdk/common/comFunc/utilhttp 看了一些引用的官方库,才发现作为私有库的...
-
13
V2EX › 程序员 GitLab CI/CD - publish 镜像到私有镜像仓库出错 JasonLaw · 4 小时 35...
-
17
本人使用Idea做Golang开发,之前一直是用公有项目,可通过快捷键自动获取(如下图),但私有git项目则不能如此顺利 不使用Go Modules(vgo)界面:
-
6
go get私有库 Published 2022年3月2日 创建1个私有代码库,以阿里云效域名为参考 https://codeup.aliyun.com/xx1/xx2,也可以换成gitlab或...
-
8
Go Get下载私有仓库的依赖 2019-03-12 19:43:22 code 约 263 字 预计阅读 1 分钟...
-
9
搭建私有 GitLab 代码托管服务器 2015-07-28 技术 ...
-
7
Harbor 安装条件 官网给出了安装需要的最低硬件和软件的条件:https://goharbor.io/docs/2.0.0/install-config/installation-prereq...
-
5
如何使用 go get 下载 gitlab 私有项目 lintingte · 2016-09-20 17:00:02 · 1972 次点击 · 预计阅读时间 73 分钟 · 大约8小时之前 开始浏览 ...
-
6
我为什么不用gitlab做私有Git服务器 作者:了不起 2024-01-31 08:15:40 选择 GitLab 还是 Gitea 取决于你的项目需求和团队规模。GitLab 提供了综合性的解决方案,适用于大型项目和团队,而 Gitea 则专注于轻量级、...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK