赞
踩
关于Go Module拉取私有仓库时,遇到terminal prompts disabled
权限的问题。
go get: gitee.com/xxxxx/proto@v1.0.0: reading https://goproxy.cn/gitee.com/xxxxxr/proto/@v/v1.0.1.info: 404 Not Found
server response:
not found: gitee.com/xxxx/proto@v1.0.1: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/vcs/38e9fe3a96fe68d3df32046929625c624d2613d5084f9e174c10834d6791c202: exit status 128:
fatal: could not read Username for 'https://gitee.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.
在go get源码包中有以下一段代码:
90 // Disable any prompting for passwords by Git.
91 // Only has an effect for 2.3.0 or later, but avoiding
92 // the prompt in earlier versions is just too hard.
93 // If user has explicitly set GIT_TERMINAL_PROMPT=1, keep
94 // prompting.
95 // See golang.org/issue/9341 and golang.org/issue/12706.
96 if os.Getenv("GIT_TERMINAL_PROMPT") == "" {
97 os.Setenv("GIT_TERMINAL_PROMPT", "0")
98 }
可以通过设置环境变量GIT_TERMINAL_PROMPT = 1
来开启账号密码的验证。
需要在仓库绑定SSH公钥
git config --global url."git@xxx.com:".insteadOf "https://xxx.com/"
配置仓库的全局选项将https
替代成ssh
通过GOPRIVATE
来指定你的仓库
go env -w GOPRIVATE=xxx.com/xxx
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。