使用 go get 获取私有 GitHub 仓库时出现 "terminal prompts disabled" 错误
你好!我是 Go 新手,尝试将私有 GitHub 仓库连接到我的项目。我已经配置了 SSH 密钥,添加到 agent,并验证了 `git clone git@github.com:myorg/myrepo.git` 无需密码即可正常工作。
但是当我执行 `go get github.com/myorg/myrepo` 时,出现以下错误:
```
go: github.com/myorg/myrepo@v0.0.0-xxxx: terminal prompts disabled
Use the 'git config core.askPass' or 'GIT_ASKPASS' environment variable, or set 'SSH_AUTH_SOCK'
```
我的 `go.mod` 中写有 `module myproject`,并添加了 `require github.com/myorg/myrepo v0.0.0`。Go 版本是 1.16,运行在 Windows 10 上。我尝试过使用 `GIT_TERMINAL_PROMPT=1` 运行,但没有帮助。在 `.gitconfig` 中,我有 `[url "git@github.com:"]` 配置,设置了 `insteadOf = https://github.com/`。但仍然不起作用。如何正确配置 Go 以便它能下载私有仓库?是否还需要在环境变量中设置其他内容?
<<>>
错误原因
Go 默认禁用了交互式