Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d657329413 | |||
| c0d0fec86b | |||
| 7d8701768d | |||
| 55d2147a6c |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
||||
bin/
|
||||
bin/*
|
||||
lookupip
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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" {
|
||||
|
||||
Reference in New Issue
Block a user