zoukankan      html  css  js  c++  java
  • go mod get go-git timeout

    在Linux上执行go build的时候,出现错误:

    build helloweb: cannot load github.com/go-git/go-git/v5: module github.com/go-git/go-git/v5: Get https://proxy.golang.org/github.com/go-git/go-git/v5/@v/list: dial tcp 34.64.4.17:443: i/o timeout
    

    查看go-git项目下的README.md文件,go-git下载方法:

    The recommended way to install go-git is:
    import "github.com/go-git/go-git/v5" // with go modules enabled (GO111MODULE=on or outside GOPATH)
    import "github.com/go-git/go-git" // with go modules disabled
    

    查看自己go环境:

    go env
    GO111MODULE=""
    GOARCH="amd64"
    GOEXE=""
    GOFLAGS=""
    GOHOSTARCH="amd64"
    GOHOSTOS="linux"
    GONOPROXY=""
    GONOSUMDB=""
    GOOS="linux"
    GOPRIVATE=""
    GOPROXY="https://proxy.golang.org,direct"
    (我删了一部分)
    

    发现自己的GO111MODULE=“”,跟官方提供的下载信息不对,因此:

    export GO111MODULE = on
    

    在运行go build,还是出现:

    build helloweb: cannot load github.com/go-git/go-git/v5: module github.com/go-git/go-git/v5: Get https://proxy.golang.org/github.com/go-git/go-git/v5/@v/list: dial tcp 34.64.4.17:443: i/o timeout
    

    网上查找go mod timeout的解决方法,发现https://proxy.golang.org被墙了,于是考虑换代理

    export GOPROXY="https://goproxy.io"
    

    运行go build成功

  • 相关阅读:
    排序与查找
    gdb
    编码风格
    数组
    结构体
    循环语句
    深入理解函数
    分支语句
    简单函数
    解决国内NPM安装依赖速度慢问题
  • 原文地址:https://www.cnblogs.com/MyUniverse/p/13054672.html
Copyright © 2011-2022 走看看