使用go get安装,老是报错:go: golang.org/x/[email protected]: unrecognized import path

go get报错

[wangzheng@wangzheng-centos ~]$ go get -u github.com/swaggo/swag/cmd/swag
package golang.org/x/net/idna: unrecognized import path "golang.org/x/net/idna" (https fetch: Get https://golang.org/x/net/idna?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
package golang.org/x/text/unicode/norm: unrecognized import path "golang.org/x/text/unicode/norm" (https fetch: Get https://golang.org/x/text/unicode/norm?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
package golang.org/x/text/width: unrecognized import path "golang.org/x/text/width" (https fetch: Get https://golang.org/x/text/width?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)

解决办法

git clone从github上下载golang代码。https://github.com/golang/tools

[wangzheng@wangzheng-centos download]$ ls golang.org/x/
net  sys  text  tools
[wangzheng@wangzheng-centos download]$ pwd
/home/wangzheng/pkg/mod/cache/download

go get安装

[wangzheng@wangzheng-centos src]$ go get github.com/swaggo/swag/cmd/swag
[wangzheng@wangzheng-centos src]$ sw
swag         swaplabel    swapoff      swapon       switch_root  

一劳永逸的办法

搞一个可以访问golang.org的~~

你可能感兴趣的:(golang)