This project can search for IP information through Maxmind geoip2 databases.
This project is built using Reader in oschwald/maxminddb-golang.
You can read Maxmind databases using a local file.
Either you can read Maxmind databases using Maxmind download URL.
If you use reading databases with Maxmind download URL(only support gzip link), it is possible to update the latest databases periodically.
It mean you will be automatically downloaded and updated to target-path in background.
So you don't need to update the latest Maxmind databases manually, So very useful.
[warning]
Maxmind download API has a daily quota of requests.
Set to appropriate update interval.
// pseudo code
package main
import (
"net"
"github.com/gjbae1212/go-geoip2"
)
func main() {
// db, err := Open("local-file-path")
db, err := OpenURL("maxmind license key", "GeoLite2-Country", "/tmp",
geoip2.WithUpdateInterval(6 * time.Hour), geoip2.WithRetries(2), geoip2.WithSuccessFunc(func(){}),...)
if err != nil {
panic(err)
}
ip := net.ParseIP("8.8.8.8")
record, err := db.City(ip)
if err != nil {
panic(err)
}
}
This project was inspired by oschwald/geoip2-golang
This project is following The MIT.