golang module logrus 被墙问题处理 - Go语言中文社区

golang module logrus 被墙问题处理


问题

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,之后再用上面的步骤执行成功了

版权声明:本文来源简书,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://www.jianshu.com/p/6a3ac27a6ffb
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-01-12 11:45:26
  • 阅读 ( 1628 )
  • 分类:Go

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢