qq相册图标怎么熄灭-电脑勒索病毒
2023年3月31日发(作者:破解开机密码)
GitLab:从内⽹拉取私有仓库gomodule
GitLab:从内⽹拉取私有仓库gomodule
golang通过gomod管理项⽬依赖。
通常,我们从github等项⽬托管平台拉取依赖gomodule。
例如:/kataras/iris/v12
假如,公司有内⽹gitlab托管项⽬代码,如何从私有仓库拉取依赖?
假设,公司的内⽹gitlab地址是:,是yyy团队下的test1280仓库。
1.设置GOPRIVATE
设置windows中的环境变量:GOPRIVATE
重启GoLand,并打开Terminal终端查看:
C:UsersEBDesktoptest1281>goenv
setGO111MODULE=on
setGOARCH=amd64
setGOBIN=
setGOCACHE=C:UsersEBAppDataLocalgo-build
setGOENV=C:UsersEBAppDataRoaminggoenv
setGOEXE=.exe
setGOFLAGS=
setGOHOSTARCH=amd64
setGOHOSTOS=windows
setGOINSECURE=
setGOMODCACHE=D:workspacegopathpkgmod
setGONOPROXY=
setGONOSUMDB=
setGOOS=windows
setGOPATH=D:workspacegopath
setGOPRIVATE=
setGOPROXY=
setGOROOT=C:ProgramFilesGo
setGOSUMDB=off
setGOTMPDIR=
setGOTOOLDIR=C:ProgramFilesGopkgtoolwindows_amd64
setGOVCS=
setGOVERSION=go1.16.4
setGCCGO=gccgo
setAR=ar
setCC=gcc
setCXX=g++
setCGO_ENABLED=1
setGOMOD=C:
setCGO_CFLAGS=-g-O2
setCGO_CPPFLAGS=
setCGO_CXXFLAGS=-g-O2
setCGO_FFLAGS=-g-O2
setCGO_LDFLAGS=-g-O2
setPKG_CONFIG=pkg-config
setGOGCCFLAGS=-m64-mthreads-fmessage-length=0-fdebug-prefix-map=C:UsersEBAppDataLocalTempgo-build1897173819=/tmp/go-build-gno-
record-
gcc-switches
注意:
a.如果windows设置GOPRIVATE,则⾃动设置GONOPROXY、GONOSUMDB。
b.不设置windows⽤户变量,仅设置GoLand项⽬配置也可以。
拉取私有仓库module
在终端执⾏:/yyy/test1280
提⽰输⼊gitlab鉴权的⽤户名称、密码:
C:UsersEBDesktoptest1281>/yyy/test1280
#get/?go-get=1
#get/yyy?go-get=1
#get/yyy/test1280?go-get=1
#get/yyy/test1280?go-get=1:200OK(0.130s)
get"/yyy/test1280":port{Prefix:"/yyy/test1280",VCS:"git",RepoRoot:"https://gitl
/yyy/"}at///yyy/test1280?go-get=1
mkdir-pD:workspacegopathpkgmodcachevcs#git3/yyy/
#lockD:workspacegopathpkgmodcachevcs5#D:workspacegopathp
kgmod
cachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7forgit3/yyy/
cachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7forgit3/yyy/
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitls-remote-qorigin
#get/?go-get=1:200OK(0.248s)
#get/yyy?go-get=1:200OK(0.259s)
68.605s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitls-remote-qorigin
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gnature=falselo
g-n
1'--format=format:%H%ct%D'30ab8436b395a56b16fc3074ea2d0458e6de720b--
0.144s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gnatur
e=fal
selog-n1'--format=format:%H%ct%D'30ab8436b395a56b16fc3074ea2d0458e6de720b--
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gittag-l
0.096s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gittag-l
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitfetch-f--depth=1origin30ab
843
6b395a56b16fc3074ea2d0458e6de720b:refs/dummy
1.970s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitfetch-f--depth=1or
igi
n30ab8436b395a56b16fc3074ea2d0458e6de720b:refs/dummy
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gnature=falselo
g-n
1'--format=format:%H%ct%D'30ab8436b395a56b16fc3074ea2d0458e6de720b--
0.068s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gnatur
e=fal
selog-n1'--format=format:%H%ct%D'30ab8436b395a56b16fc3074ea2d0458e6de720b--
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitcat-fileblob30ab8436b395a
56b16f
c3074ea2d0458e6de720b:
0.052s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitcat-fileblob30ab84
36b3
95a56b16fc3074ea2d0458e6de720b:
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitfor-each-ref--format%(refna
me)
refs/tags--merged30ab8436b395a56b16fc3074ea2d0458e6de720b
0.045s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitfor-each-ref--forma
t%(
refname)refs/tags--merged30ab8436b395a56b16fc3074ea2d0458e6de720b
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitfor-each-ref--format%(refna
me)
refs/tags--merged30ab8436b395a56b16fc3074ea2d0458e6de720b
0.044s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitfor-each-ref--forma
t%(
refname)refs/tags--merged30ab8436b395a56b16fc3074ea2d0458e6de720b
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gnature=falselo
g-n
1'--format=format:%H%ct%D'30ab8436b395--
0.043s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gnatur
e=fal
selog-n1'--format=format:%H%ct%D'30ab8436b395--
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitcat-fileblob30ab8436b395a
56b16f
c3074ea2d0458e6de720b:
0.041s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitcat-fileblob30ab84
36b3
95a56b16fc3074ea2d0458e6de720b:
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitcat-fileblob30ab8436b395a
56b16f
c3074ea2d0458e6de720b:
0.072s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitcat-fileblob30ab84
36b3
95a56b16fc3074ea2d0458e6de720b:
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitcat-fileblob30ab8436b395a
56b16f
c3074ea2d0458e6de720b:
0.043s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitcat-fileblob30ab84
36b3
36b3
95a56b16fc3074ea2d0458e6de720b:
go:/yyy/test1280v0.0.0-21-30ab8436b395
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitcat-fileblob30ab8436b395a
56b16f
c3074ea2d0458e6de720b:
0.060s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitcat-fileblob30ab84
36b3
95a56b16fc3074ea2d0458e6de720b:
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitcat-fileblob30ab8436b395a
56b16f
c3074ea2d0458e6de720b:
0.041s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;gitcat-fileblob30ab84
36b3
95a56b16fc3074ea2d0458e6de720b:
cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;lf=input-ccore.
eo
l=lfarchive--format=zip--prefix=prefix/30ab8436b395a56b16fc3074ea2d0458e6de720b
0.049s#cdD:workspacegopathpkgmodcachevcs52b930c57b03f37a1dd325269e9a6fa1e8925ecd9255ff40da8f04ff278ba5e7;lf=inp
ut-
=lfarchive--format=zip--prefix=prefix/30ab8436b395a56b16fc3074ea2d0458e6de720b
WORK=C:UsersEBAppDataLocalTempgo-build4264731656
/yyy/test1280
mkdir-p$WORKb001
cat>$WORKb001importcfg<<'EOF'#internal
#importconfig
packagefilefmt=C:ProgramFilesGopkgwindows_amd64fmt.a
EOF
cdC:UsersEBDesktoptest1281
"C:ProgramFilesGopkgtoolwindows_"-o"$WORKb001_pkg_.a"-trimpath"$WORKb001=>"-/yyy/tes
t1280-lang=go1.16-complete-buildidqNUpqkNuqz_1UjHCaxjB/qNUpqkNuqz_1UjHCaxjB-goversiongo1.16.4-D""-importcfg"$WORKb001importcfg"
-p
ack-c=4"D:test1280@"
"C:ProgramFilesGopkgtoolwindows_"-w"$WORKb001_pkg_.a"#internal
cp"$WORKb001_pkg_.a""C:UsersEBAppDataLocalgo-buildbbbbf4455401e93ebea348106585f9c272029c30221e418cde126f3b41dc3c07db-d
"#in
ternal
goget:/yyy/test1280v0.0.0-21-30ab8436b395
提⽰,新增依赖库成功:
goget:/yyy/test1280v0.0.0-21-30ab8436b395
在goget时,⾃动弹出提⽰框,要求输⼊gitlab的⽤户名称、密码。
输⼊之后,⽤户名称、密码将会存储在windows的凭据管理器中:
win+s打开搜索框,输⼊“凭据管理器”:
后续如果我们再次拉取内⽹gitlab的仓库时,系统会⾃动帮我们填充认证。
⽅式免密拉取
考虑⼀个问题:
假设gitlab的⽤户密码每天更新,每天都设置⼀次windows凭据管理器实在繁琐低效。
是否有更好的办法解决?
可设置windows⽤户公钥由gitlab信任,然后⽤户通过ssh免密拉取gitlab的代码仓库。
如何⽣成和设置windows⽤户公钥请查看:
设置完成后,我们就可以使⽤ssh免密拉取gitlab的代码仓库。
但是!
gomod使⽤的是githttp协议⽽⾮gitssh协议。
需要设置git配置:
gitconfig--globalurl."git@:".insteadof"/"
其中,需要替换成内部域名或IP地址。
⼀切都没问题了吗?
4.更好的⽅案
当内⽹gitlab的ssh服务端⼝⾮ssh默认端⼝22时,将出现问题:
即使设置:
gitconfig--globalurl."git@:10000".insteadof"/"
(其中,10000是内部gitlab的ssh服务端⼝)
实际测试,设置的10000端⼝并没有⽣效,goget调⽤git时,使⽤的仍然是22端⼝。
更好的⽅法是,通过设置netrc来实现githttp的免密,参考:
重点是!
我们可以从gitlab设置访问令牌,作为我们的永久密码存储到netrc中:
即使gitlab⽤户密码发⽣变化,gitlab⽣成的访问令牌仍然有效,我们不必修改netrc。
5.总结
从内⽹gitlab拉取私有仓库module,⾄少有三种⽅式:
1.设置netrc实现githttp免密
2.设置gitlab信任ssh公钥,通过gitconfig实现gitssh替代githttp免密
3.设置windows凭据管理器
推荐使⽤:gitlab⽣成访问令牌+设置netrc。
6.参考
更多推荐
gohost
发布评论