Golang API wrapper that finds the location of an IP address using ipapi.co.
If you purchased a paid plan, export the API Key in the environment:
export IPAPI_KEY=123456asdqwe
Returns the complete location information for an IP address specified in the function parameter.
ipapi.FindLocation("178.13.214.11")
Returns the complete location of the client (device) that’s making the request. You do not need to specify the IP address, it is inferred from the request.
ipapi.ClientLocation()
package main
import (
"fmt"
"github.com/fegoa89/ipapi"
)
func main() {
// Location of a specific IP
ipapi.FindLocation("178.13.214.11")
// Location of client's IP
ipapi.ClientLocation()
}