go get -v git.xxx.com/aaa/bbb 运行后会提示:
get "git.xxx.com/aaa/bbb": found meta tag get.metaImport{Prefix:"git.xxx.com/aaa/bbb", VCS:"git", RepoRoot:"https://git.xxxcom/aaa/bbb"} at //git.xxx.com/aaa/bbb?go-get=1
go get git.xxx.com/aaa/bbb: module git.xxx.com/aaa/bbb: git ls-remote -q origin in C:\Users\自己的用户名\go\pkg\mod\cache\vcs\02bb689e0d122333d770da2b09386d2e68d799f14e035c6871090966d5bdacf0: exit status 128:
fatal: could not read Username for 'https://git.xxx.com': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information.
如图:
![16279622851627962285_1357.png image.png](data/attachment/forum/202302/28/fddfe0b72851b71ca84168b9fbe761a3.png)
在goland中也会有相应的提示
go: git.xxx.com/aaa/bbb@v1.2.16: reading git.xxx.com/aaa/bbb/go.mod at revision v1.2.16: unknown revision v1.2.16
终极解决的方法:
1、在命令行输入以下命令:
set GOPRIVATE=git.xxx.com,git.xxx222.com
###注这里可以有多个域名用逗号隔开
2、打开文件:
C:\Users\自己的用户名\.gitconfig
加上以下代码:
[url "自己的用户名@git.xxx.com:"]
insteadOf = https://git.xxx.com/
[url "自己的用户名@git.xxx222.com:"]
insteadOf = https://git.xxx222.com/
参考地址:
https://www.jb51.net/article/211340.htm
https://segmentfault.com/a/1190000021127791
https://tomjamescn.github.io/post/2020-05-18-go-mod-private/
|