美文网首页
golang module logrus 被墙问题处理

golang module logrus 被墙问题处理

作者: dingking | 来源:发表于2019-02-27 17:10 被阅读0次

    问题

    go: golang.org/x/sys@v0.0.0-20180905080454-ebe1bf3edb33: unrecognized import path "golang.orgnrecognized import path "golang.org/x/sys" (https fetch: G1: dial tcp 216.239.37.1:443: conneet https://golang.org/x/sys?go-get=1: dial tcp 216.239.37.rty did not properly respond after1:443: connectex: A connection attempt failed because the  connected host has failed to respoconnected party did not properly respond after a period of time, or established connection failed because connected : unrecognized import path "golang.host has failed to respond.)
    ...
    go: golang.org/x/crypto@v0.0.0-20180904163835-0709b304e793nected party did not properly respo: unrecognized import path "golang.org/x/crypto" (https fed because connected host has failedtch: Get https://golang.org/x/crypto?go-get=1: dial tcp 216.239.37.1: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: error loading module requirements
    

    步骤(操作再goland,其他参考go mod的命令)

    1.引入github.com/sirupsen/logrus

    //对着github.com/sirupsen/logrus win(alt+enter)进行引入
    import (
        "fmt"
        "github.com/gin-gonic/gin"
        log "github.com/sirupsen/logrus"
        "net/http"
        "subject_system/config"
    )
    

    引入会出现下面类似错误

    go: golang.org/x/sys@v0.0.0-20180905080454-ebe1bf3edb33: unrecognized import
    go: golang.org/x/crypto@v0.0.0-20180904163835-0709b304e793: unrecognized import
    

    记住这个版本号golang.org/x/sys@v0.0.0-20180905080454-ebe1bf3edb33
    golang.org/x/crypto@v0.0.0-20180904163835-0709b304e793
    2.在go.mod文件里面添加

    replace golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 => github.com/golang/crypto v0.0.0-20180904163835-0709b304e793
    
    replace golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 => github.com/golang/sys v0.0.0-20180905080454-ebe1bf3edb33
    

    3.添加完成执行go build
    4.再次执行引入github.com/sirupsen/logrus操作,等待下载完成

    第一次处理时候的问题

    因为本地误删除一些包,导致一直执行不了,之后再没有执行引入github.com/sirupsen/logrus之前进行了一次go mod tidy,之后再用上面的步骤执行成功了

    相关文章

      网友评论

          本文标题:golang module logrus 被墙问题处理

          本文链接:https://www.haomeiwen.com/subject/swbfuqtx.html