@H_404_1@
package main
import (
"fmt"
"io/IoUtil"
"net/http"
"time"
)
func main() {
for true{
getUrl();
time.Sleep(time.Duration(10)*time.Second)
}
}
func getUrl(){
url := "https://www.pang.com/api/xx"
req,_ := http.NewRequest("GET",url,nil)
res,_ := http.DefaultClient.Do(req)
defer res.Body.Close()
body,_ := IoUtil.ReadAll(res.Body)
fmt.Println(string(body))
}
----------------------
参考:
golang post和get发送请求
http://www.361way.com/golang-post-get/5861.htmlgolang sleep
https://blog.csdn.net/lanyang123456/article/details/78158457