我已经正确配置了ssh,可以通过ssh处理我们的私有repo中的git内容。但是当我使用go get
或go test
(针对go modules)进行测试时,命令行界面却没有使用ssh,而是使用https。
.gitconfig
[url "ssh://git@bitbucket.company.com:7999"]
insteadOf = https://bitbucket.company.com/scm
~/.ssh/config
Host bitbucket.company.com
User git
Port 7999
IdentityFile ~/.ssh/id_rsa
测试 SSH 是否正常工作
$ git ls-remote ssh://git@bitbucket.company.com:7999/project/repo.git
ab86e12ab20775a308b7d0b003ba562263fbfa23 HEAD
ab86e12ab20775a308b7d0b003ba562263fbfa23 refs/heads/master
ab86e12ab20775a308b7d0b003ba562263fbfa23 refs/tags/v0.0.1
测试go get
$ go get -v bitbucket.company.com/project/repo
go get bitbucket.company.com/project/repo: unrecognized import path "bitbucket.company.com/project/repo": https fetch: Get "https://bitbucket.company.com/project/repo?go-get=1": dial tcp 10.68.204.3: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.
go version
go version go1.14.1 windows/amd64
go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\sailhenz\AppData\Local\go-build
set GOENV=C:\Users\sailhenz\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=none
set GONOSUMDB=*.company.com
set GOOS=windows
set GOPATH=C:\Users\sailhenz\Documents\Development\Go
set GOPRIVATE=*.company.com
set GOPROXY=https://goproxy.io,direct
set GOROOT=C:\Users\sailhenz\Documents\Software\go
set GOSUMDB=off
set GOTMPDIR=
set GOTOOLDIR=C:\Users\sailhenz\Documents\Software\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\sail~1\AppData\Local\Temp\go-build227330694=/tmp/go-build -gno-record-gcc-switches
我是否错过了任何设置或配置?提前感谢。
bitbucket.company.com/project/repo
与https://bitbucket.company.com/scm
不匹配。 - ElpieKay.git
可以解决它。这里是线程链接https://github.com/golang/go/issues/27254,供有相同问题的人参考。 - sailhenz.git
导致的问题。 - VonC