新聞中心
本文由
golang教程欄目給大家總結(jié)介紹go get怎么安裝gitlab私有包,希望對需要的朋友有所幫助!

創(chuàng)新互聯(lián)建站是專業(yè)的永年網(wǎng)站建設(shè)公司,永年接單;提供成都網(wǎng)站設(shè)計、網(wǎng)站制作,網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行永年網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊,希望更多企業(yè)前來合作!
-
獲取gitlab的token
進(jìn)入Gitlab—>Settings—>Access Tokens,然后創(chuàng)建一個personal access token,這里權(quán)限最好選擇只讀(read_repository)。
-
git配置添加access token
有了access token后,我們還需要在git中進(jìn)行配置,這樣才能go get下了私有倉庫的包,需要把剛剛的token添加進(jìn)git的請求頭中,操作如下:
git config --global http.extraheader "PRIVATE-TOKEN: YOUR_PRIVATE_TOKEN"
- 配置git將請求從ssh轉(zhuǎn)換為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}}/
- 如果這樣還拉不下來,就需要對go的一些環(huán)境變量進(jìn)行配置
Bash (Liunx or macOS)
# 配置 GOPROXY 環(huán)境變量 export GOPROXY=https://goproxy.io,direct # 還可以設(shè)置不走 proxy 的私有倉庫或組,多個用逗號相隔(可選) export GOPRIVATE=git.mycompany.com,github.com/my/private
Powerbash (Windows)
# 配置 GOPROXY 環(huán)境變量 $env:GOPROXY = "https://goproxy.io,direct" # 還可以設(shè)置不走 proxy 的私有倉庫或組,多個用逗號相隔(可選) $env:GOPRIVATE = "git.mycompany.com,github.com/my/private"
本文標(biāo)題:講解goget如何安裝gitlab私有包
文章源于:http://m.fisionsoft.com.cn/article/dhhhgod.html


咨詢
建站咨詢
