# README
go-geoip2
Overview
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.
Getting Started
// 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)
}
}
Inspiration
This project was inspired by oschwald/geoip2-golang
LICENSE
This project is following The MIT.
# Functions
maxmindDownloadURL returns Maxmind download URL reference: maxmind URL https://dev.maxmind.com/geoip/geoipupdate/#Direct_Downloads.
Open returns geoip Reader from a local file.
OpenURL returns geoip Reader from maxmind download URL and updates automatically the latest maxmind databases.
WithErrorFunc returns a function for setting a method to call if a download failed.
WithFirstDownloadWait returns a function for setting first download wait time.
WithUpdateInterval returns a function for setting download retry count if a download is failed.
WithSuccessFunc returns a function for setting a method to call if a download succeeded.
WithUpdateInterval returns a function for setting download time interval.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
support to interface for oschwald/geoip2-golang.
# Type aliases
No description provided by the author
No description provided by the author