如何消除go get依赖项检查?

When I exec go get -u github.com/spf13/viper, which has a dependency golang.org/x/sys.It will auto-execute cd ${GOPATH}/src/golang.org/x/sys; git pull --ff-only.

This is really extra no use.

My network can't reach golang.org/x/sys. So I've already used github.com/golang/sys and put it into my GOPATH/src/golang.org/x.Which means the auto-check(cd ${GOPATH}/src/golang.org/x/sys; git pull --ff-only) for the progress(go get -u github.com/spf13/viper) should be totally eliminated, because it stuck my jenkins deploy time.

More than 90% time of jenkins deployment is wasted in checks like

cd ${GOPATH}/src/golang.org/x/sys; git pull --ff-only

cd ${GOPATH}/src/golang.org/x/text; git pull --ff-only

...

Here is part of my jenkins log:

# cd /home/tonnn/go/src/golang.org/x/sys; git pull --ff-only
fatal: unable to access 'https://go.googlesource.com/sys/': Failed connect to go.googlesource.com:443; Connection timed out
package golang.org/x/sys/unix: exit status 1

# cd /home/tonnn/go/src/golang.org/x/text; git pull --ff-only
fatal: unable to access 'https://go.googlesource.com/text/': Failed connect to go.googlesource.com:443; Connection timed out

So, is there a way to only get viper but do not check its dependencies?

viper is only an example to show my question.I bet most of you have met this kind of question.

I'm using Go 1.9.

Embarassed to answer the question myself but I do find its solution.

When ${GOPATH}/src/golang.org/x/sys already exists before you fetch from github.com/golang/sys.It will jump this stage and cause an occasion that when you execute git remote -v.It will list origin https://go.googlesource.com/sys fetch/push.This is exactly what causes my stuck fetch googlesource.com/sys time out.

Ok,Now there is two way to fix it.

First way, remove existed package and make it exactly fetched from github.com/golang/sys. rm -rf ${GOPATH}/src/golang.org/x/sys.After jenkins shell jobs, its git remote will correctly convert to https://github.com/golang/sys

Second way, change its origin remote.

cd ${GOPATH}/src/golang.org/x/sys
git remote remove origin
git remote add origin https://github.com/golang/sys.git

Hope it helpful to all of you.