golang implementation of MaxMind's GeoIP2 Precision Services
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example - added license information Jul 27, 2015
.gitignore updated .gitignore Jul 26, 2015
LICENSE - added license information Jul 27, 2015
README.md - initial commit Jul 26, 2015
examples_test.go - added license information Jul 27, 2015
geoip2.go
geoip2_test.go - added license information Jul 27, 2015
types.go - added license information Jul 27, 2015

README.md

geoip2

golang implementation of MaxMind's GeoIP2 Precision Services

Example

Simple example to use the maxmind realtime api to perform a geo-query. While City takes an optional context.Context parameter, you can pass in nil if you don't care to use this.

package main

import (
	"os"
	"encoding/json"

	"github.com/savaki/geoip2"
)

func main() {
	api := geoip2.New(os.Getenv("MAXMIND_USER_ID"), os.Getenv("MAXMIND_LICENSE_KEY"))
	resp, _ := api.City(nil, "1.2.3.4")
	json.NewEncoder(os.Stdout).Encode(resp)
}