gpt4 book ai didi

go - 如何使用 "go get"安装软件包

转载 作者:行者123 更新时间:2023-12-01 21:13:43 25 4
gpt4 key购买 nike

我最近设置了 Go,但我无法使用 go get 安装包.我尝试了针对类似问题发布的建议,但没有运气。

对于我尝试安装的任何软件包,我都会得到以下信息:

# cd .; git clone -- https://github.com/gorilla/mux /Users/Dan/Desktop/goworkspace/src/github.com/gorilla/mux
Cloning into '/Users/Dan/Desktop/goworkspace/src/github.com/gorilla/mux'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
package github.com/gorilla/mux: exit status 128

这是我的 Go 环境:
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/Dan/Library/Caches/go-build"
GOENV="/Users/Dan/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/Dan/Desktop/goworkspace"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/j4/ntt6p0qn76v46thx2gnqxkm80000gn/T/go-build360206970=/tmp/go-build -gno-record-gcc-switches -fno-common"

最佳答案

如果您不得不摆弄受密码保护的私有(private) SSH key (要添加到 ssh 代理),这意味着您必须拥有 git config --global -l像这样的设置:

[url "git@github.com:"]
insteadOf = https://github.com/

因为,如 golang/go issue 6968 所示, 一个 go get一般会 use the HTTPS URL by default ,以及存储库 github.com/gorilla/mux 是一个公共(public)的,应该可以立即工作,而无需使用 SSH key 。

所以删除该设置。

如果需要SSH,可以限制只对GitHub进行推送操作, as discussed here :
[url "git@github.com/"]
pushInsteadOf = https://github.com/

关于go - 如何使用 "go get"安装软件包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61901040/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com