From 5417d46dea3ecbb91783f02cbc1a835f21c85cfb Mon Sep 17 00:00:00 2001 From: wangsiyuan <2392948297@qq.com> Date: Mon, 5 Jun 2023 17:18:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加读取路径下的配置文件 --- main.go | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/main.go b/main.go index 4585ea9..c7e79be 100644 --- a/main.go +++ b/main.go @@ -9,39 +9,6 @@ import ( "net/http" ) -//func main() { -// //modules.ImportDatabaseToHex() -// http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { -// //测试用ip地址 -// ip := "125.71.133.170" -// //获取访问浏览器ip -// //ip := strings.Split(r.RemoteAddr, ":")[0] -// //fmt.Println("客户端IP地址:", ip) -// log.Println("客户端ip:", ip) -// //使用mmdb查询ip -// IpIformation := modules.MmdbQueryIP(ip) -// //使用MySql查询ip -// -// log.Println(IpIformation) -// jsonData, err := json.Marshal(IpIformation) -// if err != nil { -// fmt.Println("JSON 序列化失败:", err) -// return -// } -// // 设置响应的 Content-Type 为 application/json -// w.Header().Set("Content-Type", "application/json") -// // 返回 JSON 数据 -// print(jsonData) -// w.Write(jsonData) -// }) -// http.ListenAndServe(":8341", nil) -//} - -//func main() { -// modules.ImportLocation_zhCN() -// modules.ImportLocation_en() -//} - func main() { //modules.ImportDatabaseToHex() http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -54,7 +21,9 @@ func main() { //使用mmdb查询ip //IpIformation := modules.MmdbQueryIP(ip) //使用MySql查询ip - IpIformation := modules.MysqlQuery(ip) + dsn := modules.Readconfig() + //fmt.Println(dsn) + IpIformation := modules.MysqlQuery(ip, dsn) log.Println("tag:main", IpIformation) jsonData, err := json.Marshal(IpIformation) if err != nil {