You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
426 B
24 lines
426 B
2 years ago
|
package geoip
|
||
|
|
||
|
import (
|
||
|
"io/ioutil"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
func OnlineDownload(downloadUrl string, downloadName string) {
|
||
|
resp, err := http.Get(downloadUrl)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
defer resp.Body.Close()
|
||
|
|
||
|
body, err := ioutil.ReadAll(resp.Body)
|
||
|
|
||
|
err = ioutil.WriteFile("./"+downloadName, body, 0644)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
log.Printf("已下载最新 ip2region.xdb 数据库 %s ", "./"+downloadName)
|
||
|
}
|