go mod的使用
在使用golang进行项目开发过程中,经常会使用go module来进行依赖包的管理。本章讲述一下go module的使用。
1. 解决golang.org不能访问
在国内golang.org被屏蔽了,直接访问不了,我们采用如下办法解决:在http://ping.eu/ping/上ping一下golang.org
,获取到IP如下图所示:
然后,在C:\Windows\System32\drivers\etc\hosts
中,添加ip和golang.org的对应关系,添加如下一行:
# lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost #140.82.113.4 github.com #140.82.113.4 www.github.com #199.232.69.194 github.global.ssl.fastly.net #199.232.69.194 github.com.global.ssl.fastly.net #199.232.69.194 www.github.global.ssl.fastly.net #185.199.108.153 assets-cdn.github.com #185.199.109.153 assets-cdn.github.com #185.199.110.153 assets-cdn.github.com #185.199.111.153 assets-cdn.github.com #142.250.74.113 blog.golang.org 142.250.74.113 golang.org #216.239.38.21 go.dev #142.250.74.19 pkg.go.dev #142.250.74.113 play.golang.org
然后启动windows命令行,执行:
# ipconfig/flushdns
之后重新启动下浏览器,就可访问golang.org了。
[参看]: