我想通過 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 hereresp, err := http.Get(url1)注意:如果我直接在網站上打開,我可以正常訪問該文件。
1 回答

慕碼人8056858
TA貢獻1803條經驗 獲得超6個贊
此錯誤消息與 WinsockWSANO_DATA
錯誤代碼相關聯。這意味著,您嘗試連接的域名的 DNS 記錄存在問題。
見這里: https ://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2#WSANO_DATA
我認為重新啟動服務器可能會解決它。
您應該調查環境的 DNS 設置
如果您手動輸入地址,請確保拼寫正確
嘗試手動輸入 URL
- 1 回答
- 0 關注
- 360 瀏覽
添加回答
舉報
0/150
提交
取消