goland 循环geturl

180it 2021-09-24 AM 1379℃ 0条
package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
    "time"
)


func main() {
    go func() {
        for {
            fmt.Println("windows下的另一种DLL方法调用HELLO !")
            time.Sleep(10 * time.Second)
            getUrl()
        }
    }()
    select {}
}


func getUrl(){
    url := "http://xxx.xxx.com/api_getcount.php"
    req, _ := http.NewRequest("GET", url, nil)
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)
    fmt.Println(string(body))
    time.Sleep(time.Duration(5)*time.Second)
    fmt.Println("\r\n")
}

支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

goland 循环geturl