package main import ( "encoding/json" "net/http" "os/user" "path/filepath" ) func home(path string) string { usr, err := user.Current() if err != nil { panic(err) } return filepath.Join(usr.HomeDir, path) } type freegeoipResponse struct { Lat float64 `json:"latitude"` Lng float64 `json:"longitude"` } func whereami() (lat float64, lng float64, err error) { resp, err := http.Get("https://freegeoip.app/json/") if err != nil { return 0, 0, err } var res freegeoipResponse err = json.NewDecoder(resp.Body).Decode(&res) if err != nil { return 0, 0, err } return res.Lat, res.Lng, nil }