add probe folder

This commit is contained in:
2025-04-29 23:31:22 +02:00
parent e540cdefc0
commit 371b44422b
5 changed files with 234 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
package geo
import (
"encoding/json"
"net/http"
)
type GeoInfo struct {
Country string `json:"country"`
Region string `json:"regionName"`
City string `json:"city"`
}
func GetGeoLocation() GeoInfo {
resp, err := http.Get("http://ip-api.com/json")
if err != nil {
return GeoInfo{Country: "Unknown", Region: "Unknown", City: "Unknown"}
}
defer resp.Body.Close()
var info GeoInfo
json.NewDecoder(resp.Body).Decode(&info)
return info
}