douque8855 2019-09-11 07:59
浏览 146

如何消除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.

  • 写回答

1条回答 默认 最新

  • doucuo1642 2019-09-11 08:53
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端