go get 下载包时提示 could not read Username


问题

在下载公司内部的包时,出现如下提示:

go get: module example.com/somepkg/common: git ls-remote -q origin in /somepath/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx: exit status 128:
        fatal: could not read Username for 'https://xxx.example.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.

原因

查询了下必应,大致原因是,下载包时,没有用户名和密码,导致没有权限,因此需要启用弹窗,以便输入用户名和密码。

解决

设置环境变量:GIT_TERMINAL_PROMPT 为 1

也可以在你 go get example.com/some/pkg 时,直接设置:GIT_TERMINAL_PROMPT=1 go get -u example.com/path/yourpkg

同时为了能在以后不用再输入用户名和密码,可以设定储存密码:

git config --global credential.helper store

参考


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM