4 Commits

5 changed files with 61 additions and 61 deletions

2
.gitignore vendored
View File

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

View File

@@ -1,11 +1,11 @@
# 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/
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

View File

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