go依赖包安装报错:unrecognized import path golang.org/x/crypto/ssh/terminal

使用 godep报错

$godep restore
godep: [WARNING]: godep should only be used inside a valid go package directory and
godep: [WARNING]: may not function correctly. You are probably outside of your $GOPATH.
godep: [WARNING]:	Current Directory: /root/go/k8s-controller-custom-resource
godep: [WARNING]:	$GOPATH: /root/go
godep: error downloading dep (golang.org/x/crypto/ssh/terminal): unrecognized import path "golang.org/x/crypto/ssh/terminal"

尝试使用golang提供的公共代理服务 GOPROXY

$export GOPROXY=https://goproxy.io
$export GO111MODULE=on
$cd /root/go/k8s-controller-custom-resource
$go mod init
warning: GOPATH set to GOROOT (/root/go/k8s-controller-custom-resource) has no effect
go: creating new go.mod: module k8s.io/sample-controller
go: copying requirements from Godeps/Godeps.json
....
$export GOPATH=/root/go
$go mod download

你可能感兴趣的:(golang)