Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用go get要求WSL 2上的私有github repo具有依赖性_Go_Github_Wsl 2_Git Credential Manager_Go Get - Fatal编程技术网

使用go get要求WSL 2上的私有github repo具有依赖性

使用go get要求WSL 2上的私有github repo具有依赖性,go,github,wsl-2,git-credential-manager,go-get,Go,Github,Wsl 2,Git Credential Manager,Go Get,我正在windows 10上试用WSL 2,到目前为止效果很好,但我已经为此奋斗了两周,因为出于某种原因,go get不使用或无法使Git Credentials Manager提示输入我的凭据 我跟随这个博客用GCM建立了WSL2 它对大多数日常任务都很有效,比如克隆、读写。但是当使用go-get时,我得到了这个错误 go get <remote github repo>@<latest commit id> go: <remote github repo>

我正在windows 10上试用WSL 2,到目前为止效果很好,但我已经为此奋斗了两周,因为出于某种原因,
go get
不使用或无法使Git Credentials Manager提示输入我的凭据

我跟随这个博客用GCM建立了WSL2

它对大多数日常任务都很有效,比如克隆、读写。但是当使用
go-get
时,我得到了这个错误

go get <remote github repo>@<latest commit id>
go: <remote github repo> 681dceefc81203e094872401c184d038090d6049 => v0.0.17-0.20200501212733-681dceefc812
go get: <remote github repo>@v0.0.17-0.20200501212733-681dceefc812/go.mod: verifying module: <remote github repo>@v0.0.17-0.20200501212733-681dceefc812/go.mod: reading https://sum.golang.org/lookup/<remote github repo>@v0.0.17-0.20200501212733-681dceefc812: 410 Gone
        server response:
        not found: <remote github repo>@v0.0.17-0.20200501212733-681dceefc812: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/232ff028cb2fdebd254e30bfc612843483f0fe3fbeb18d5fc8fb4b20f21c9021: exit status 128:
                fatal: could not read Username for 'https://github.com': terminal prompts disabled
go-get@
go:681dceefc81203e094872401c184d038090d6049=>v0.0.17-0.20200501212733-681dceefc812
go get:@v0.0.17-0.20200501212733-681dceefc812/go.mod:验证模块:@v0.0.17-0.20200501212733-681dceefc812/go.mod:读取https://sum.golang.org/lookup/@v0.0.17-0.20200501212733-681dceefc812:410消失
服务器响应:
未找到:@v0.0.17-0.20200501212733-681dceefc812:无效版本:git fetch-f origin refs/heads/*:refs/heads/*refs/tags/*:refs/tags/*in/tmp/gopath/pkg/mod/cache/vcs/232ff02cb2fd25e30bfc6128483f0f0fe3fbeb18fb4b20f21c9021:退出状态128:
致命:无法读取的用户名'https://github.com':终端提示已禁用
已经尝试过ssh密钥和这里提出的解决方案

但是错误仍然是一样的,当启用env
GIT_TERMINAL\u PROMPT=1时,什么也没有发生,我想这是因为WSL2没有这样做的权限。无论如何,我也尝试了这个工具,通过为普通凭证存储设置一个变量,它会在终端中提示输入凭证。但我使用2FA是因为它是组织所必需的,提示只要求输入用户名和密码,所以身份验证失败

所以我必须找到一个使用Mac的伙伴。他能够
go获得影响
go.mod
的依赖项,进行提交并推动更改,这样我就可以从中提取并继续。但当然这并不理想,他也没有任何问题,他使用osxkeychain来管理他的git凭证


有人面临过这个问题吗?或者知道如何解决它?提前非常感谢。

Go无法理解某些模块是私有的,它们的校验和不应根据Go的校验和库进行验证。下面的错误来自于此

verifying module: <remote github repo>@v0.0.17-0.20200501212733-681dceefc812/go.mod: reading https://sum.golang.org/lookup/<remote github repo>@v0.0.17-0.20200501212733-681dceefc812: 410 Gone
验证模块:@v0.0.17-0.20200501212733-681dceefc812/go.mod:读取https://sum.golang.org/lookup/@v0.0.17-0.20200501212733-681dceefc812:410消失
如果可能,至少使用1.13或更高。Go通过名称
GOPRIVATE
GONOPROXY
GONOSUMDB
引入了一个env变量,以便更好地管理私有模块。最简单的方法是使用
GOPRIVATE
,来表示您正在导入私有回购协议。将私有回购模式设置为
GOPRIVATE
env变量,以禁止校验和验证和使用
GOPROXY
。以下示例避免了该层次结构中所有回购协议的校验和:

GOPRIVATE=github.com/*


查看答案和答案。您也可以使用
go help module private
获取帮助。

>但我使用2FA是因为组织需要它,提示只要求输入用户名和密码,因此身份验证失败。注意:您应该能够输入用户名和PAT(个人访问令牌)作为密码。非常感谢!当我这样做时,我能够成功地进行身份验证,但是服务器响应显示了相同的错误。我开始认为这与用户身份验证无关,而是一个权限问题。我使用的是Go 1.14,依赖关系使用的是Go 1.12。但是通过使用
GOPRIVATE=go get…
我能够让它工作!谢谢。我认为这个答案是正确的。