我想通過raw.githubusercontent.com下載github中的一些檔案。
在使用golang實作這個功能的時候,遇到如下錯誤:
dial tcp: lookup raw.githubusercontent.com: getaddrinfow: The requested name is valid, but no data of the requested type was found.
我的代碼:
url1 := "https://raw.githubusercontent.com/pupillord/tiny-cs/main/README.md"
// the error mentioned above will appear here
resp, err := http.Get(url1)
注意:如果直接在網站上打開,可以正常訪問檔案。
uj5u.com熱心網友回復:
此錯誤訊息與 WinsockWSANO_DATA錯誤代碼相關聯。這意味著,您嘗試連接的域名的 DNS 記錄存在問題。
請參閱此處:https : //docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2#WSANO_DATA
- 我認為重新啟動服務器可能會解決它。
- 您應該調查您環境的 DNS 設定
- 如果您手動輸入地址,請確保拼寫正確
- 嘗試手動輸入 URL
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/404473.html
標籤:
