我最近设置了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
这是我的围棋环境:
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"
答案 0 :(得分:0)
如果您不得不摆弄密码保护的私密SSH密钥(要添加到ssh-agent中),这意味着您必须在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
是公共的,因此应该立即工作,而不必完全使用SSH密钥。
因此删除该设置。
如果需要SSH,则可以仅对GitHub as discussed here限制推送操作:
[url "git@github.com/"]
pushInsteadOf = https://github.com/