问题
初始学习go语言的过程中,使用rsc.io/quote库编写代码如下代码后,使用使用go mod tidy语句报错:
package main
import "fmt"
import "rsc.io/quote"
func main() {
fmt.Println(quote.Go())
}
报错信息为:
A connection attempt failed because the connected party did not properly respond ...
解决方案
原因其实也很简单,就是被墙了。使用默认的https://golang.org/这个代理下载对应的库是会被墙的,所以我们需要更改代理。
采用如下博客中的方法一,并未解决问题
博客地址:https://blog.csdn.net/qq_35566365/article/details/100598621
失败,报错情况如下:

采用上述博客的第二种方法成功,使用指令更改修改代理后成功。
go env -w GOPROXY=https://goproxy.io,direct
运行程序:
go run .
控制台上显示如下信息,程序成功运行,代理被修改了。
Don't communicate by sharing memory, share memory by communicating.
参考链接: