4 Commits

5 changed files with 61 additions and 61 deletions

View File

@@ -1,25 +1,25 @@
name: Go
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
name: Go
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...

2
.gitignore vendored
View File

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

50
.vscode/tasks.json vendored
View File

@@ -1,26 +1,26 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Go Build",
"type": "shell",
"command": "go build -o bin/",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "silent",
"clear": true
}
},
{
"label": "Go Test All",
"type": "shell",
"command": "go test ./...",
"problemMatcher": []
}
]
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Go Build",
"type": "shell",
"command": "go build -o bin/",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "silent",
"clear": true
}
},
{
"label": "Go Test All",
"type": "shell",
"command": "go test ./...",
"problemMatcher": []
}
]
}

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" {