go mod tidy報錯:A connection attempt failed because the connected party did not properly respond


問題

初始學習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.


參考鏈接:

https://blog.csdn.net/qq_35566365/article/details/100598621

https://goproxy.io/zh/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM