Example #1
0
func ExampleApi_City() {
	userId := os.Getenv("MAXMIND_USER_ID")
	licenseKey := os.Getenv("MAXMIND_LICENSE_KEY")
	api := geoip2.New(userId, licenseKey)

	resp, _ := api.City(nil, "1.2.3.4")
	json.NewEncoder(os.Stdout).Encode(resp)
}
Example #2
0
func ExampleApi_Insights() {
	userId := os.Getenv("MAXMIND_USER_ID")
	licenseKey := os.Getenv("MAXMIND_LICENSE_KEY")
	api := geoip2.New(userId, licenseKey)

	ctx, _ := context.WithTimeout(context.Background(), 3*time.Second)
	resp, _ := api.Insights(ctx, "1.2.3.4")
	json.NewEncoder(os.Stdout).Encode(resp)
}
Example #3
0
func (c *GeoIPConfig) Api() *geoip2.Api { return geoip2.New(c.UserID, c.LicenseKey) }
Example #4
0
func main() {
	api := geoip2.New(os.Getenv("MAXMIND_USER_ID"), os.Getenv("MAXMIND_LICENSE_KEY"))
	resp, _ := api.City(nil, "8.8.8.8")
	json.NewEncoder(os.Stdout).Encode(resp)
}