找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 319|回复: 0

[其它] go get 后 fatal: could not read Username for 'https://git.xxx.com': terminal pro

  [复制链接]
发表于 2023-2-28 21:23 | 显示全部楼层 |阅读模式

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.

 

如图:

image.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/

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|学习笔记

GMT+8, 2024-9-8 09:10 , Processed in 0.019508 second(s), 14 queries , APCu On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表