栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Go语言

Go Module 私有仓库:fatal: could not read Username for ‘https://xxx.com‘: terminal prompts disabled

Go语言 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Go Module 私有仓库:fatal: could not read Username for ‘https://xxx.com‘: terminal prompts disabled

说明

关于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.
设置GIT_TERMINAL_PROMPT

在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 来开启账号密码的验证。

https替换成ssh

需要在仓库绑定SSH公钥

git config --global url."git@xxx.com:".insteadOf "https://xxx.com/"

配置仓库的全局选项将https替代成ssh

设置 GOPRIVATE

通过GOPRIVATE来指定你的仓库

go env -w GOPRIVATE=xxx.com/xxx
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/907738.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号