4 Commits

5 changed files with 61 additions and 61 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,2 @@
bin/ bin/*
lookupip lookupip

View File

@@ -1,11 +1,11 @@
# lookupip # lookupip
Simple go executable to task an ip and get the results from ip-api Simple Go executable to query an IP and get the results from ip-api:
https://ip-api.com/ https://ip-api.com/
This is a fantastic site and I hope the continue to provide this This is a fantastic site, and I hope they continue to provide this service.
Allows flag -p to replace the properties output Allows flag -p to replace the properties output.
## Build ## Build

View File

@@ -63,21 +63,21 @@ func buildURL(ip string) (string, error) {
// https://ip-api.com/docs/api:json // https://ip-api.com/docs/api:json
func Lookup(ip string) (data IPAPI, err error) { func Lookup(ip string) (data IPAPI, err error) {
url, error := buildURL(ip) url, err := buildURL(ip)
if error != nil { if err != nil {
return data, error return data, err
} }
resp, err := http.Get(url) resp, err := http.Get(url)
if error != nil { if err != nil {
return data, error return data, err
} }
defer resp.Body.Close() defer resp.Body.Close()
err = json.NewDecoder(resp.Body).Decode(&data) err = json.NewDecoder(resp.Body).Decode(&data)
if error != nil { if err != nil {
return data, error return data, err
} }
if data.Status == "fail" { if data.Status == "fail" {