我在 Golang 中的一个简单的 HTTP Get 请求有一个非常奇怪的问题。
Golang 中对https://www.alltron.ch/json/searchSuggestion?searchTerm=notebook 的每个请求大约需要 6-8 秒(!)
如果在Chrome、Postman 或 Powershell 中触发了相同的请求,则只需不到一秒钟。
有人知道为什么会发生这种情况吗?
我的代码:
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://www.alltron.ch/json/searchSuggestion?searchTerm=notebook", nil)
response, err := client.Do(req)
if err != nil && response == nil {
log.Fatalf("Error on request. %v", err)
}
defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body)
if err != nil {
log.Fatalf("Couldn't get response body. %v", err) …Run Code Online (Sandbox Code Playgroud)