1、设置GOPRIVATE
go env -w GOPRIVATE=gitlab.com
2、设置git代理(用的是本地虚拟机gitlab,虚拟机ip是192.168.56.102,没有设置域名),root是gitlab的用户名
[url "git@192.168.56.102:root/"]
insteadOf = https://gitlab.com/root/
3、下载依赖(要加上root,test项目是用root用户在gitlab上创建的)
go get gitlab.com/root/test
4、下载成功
>go get gitlab.com/root/test
>go: downloading gitlab.com/root/test v0.0.0-20230411172232-fac87f053e67
>go: added gitlab.com/root/test v0.0.0-20230411172232-fac87f053e67
5、总结
(1)go get gitlab.com判断go get的解析方式为:域名/用户/仓库
(2)后续有新的理解再修改