美文网首页
go常见问题

go常见问题

作者: 呦丶耍脾气 | 来源:发表于2024-05-22 10:39 被阅读0次

1. fatal: could not read Username for 'https://github.com': terminal prompts disabled

  • 问题
PS C:\wwwroot\wm-light-practice> go mod tidy                                                                                       
go: gitlab.weimiaocaishang.com/components/go-jaeger@v0.1.8 requires
        gitlab.weimiaocaishang.com/components/go-gin@v1.1.18 requires
        github.com/go-xorm/xorm@v0.7.9: reading github.com/go-xorm/xorm/go.mod at revision v0.7.9: git ls-remote -q origin in C:\Users\Administrator\go\pkg\mod\cache\vcs\516cff95263076be8ff66fbbae295f8235963b00c4f114bcea50f99a51def2
72: exit status 128:
        fatal: Cannot prompt because user interactivity has been disabled.
        fatal: could not read Username for 'https://github.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.
  • 解决
    ssh链接方式,需要开启ssh密钥链接:参考
git config --global --add url."git@github.com:".insteadOf "https://github.com/"

2. fatal: Could not read from remote repository.

当配置好github 的ssh链接后,需要链接以下,执行下面命令

fatal: Could not read from remote repository.

        Please make sure you have the correct access rights
        and the repository exists.

  • 解决
$ ssh -t git@github.com
# Hi 用户! You've successfully authenticated, but GitHub does not provide shell access.

3. missing go.sum entry for module providing package

依赖下载完成后,启动测试文件报错
报错:

FAIL    github.com/xx/xx [setup failed]
github.com/xx/xx
FAIL
if_test.go:5:2: missing go.sum entry for module providing package 

解决:让命令程序同时下载并安装指定的代码包中的测试源码文件中依赖的代码包

go get -t github.com/xx/xx

4. dial tcp 142.251.211.241:443: connectex

执行go get github.com/cockroachdb/errors报错:

go: github.com/cockroachdb/errors@upgrade (v1.11.3) requires google.golang.org/protobuf@v1.33.0: Get "https://proxy.golang.org/google.golang.org/protobuf/@v/v1.33.0.mod": dial tcp 142.251.211.241:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

更换一个国内能访问的代理地址:https://goproxy.cn
执行命令:

go env -w GOPROXY=https://goproxy.cn

相关文章

网友评论

      本文标题:go常见问题

      本文链接:https://www.haomeiwen.com/subject/yzdrddtx.html