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