Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Api ¶
type Api struct {
// contains filtered or unexported fields
}
func WithClientFunc ¶
func (*Api) City ¶
Example ¶
package main import ( "encoding/json" "os" "github.com/savaki/geoip2" ) func main() { 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) }
Output:
func (*Api) Country ¶
Example ¶
package main import ( "encoding/json" "os" "time" "github.com/savaki/geoip2" "golang.org/x/net/context" ) func main() { 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.Country(ctx, "1.2.3.4") json.NewEncoder(os.Stdout).Encode(resp) }
Output:
func (*Api) Insights ¶
Example ¶
package main import ( "encoding/json" "os" "time" "github.com/savaki/geoip2" "golang.org/x/net/context" ) func main() { 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) }
Output:
type Location ¶
type Location struct { AccuracyRadius int `json:"accuracy_radius,omitempty"` AverageIncome int `json:"average_income,omitempty"` Latitude float64 `json:"latitude,omitempty"` Longitude float64 `json:"longitude,omitempty"` MetroCode int `json:"metro_code,omitempty"` PopulationDensity int `json:"population_density,omitempty"` TimeZone string `json:"time_zone,omitempty"` }
type RegisteredCountry ¶
type RepresentedCountry ¶
type Response ¶
type Response struct { City City `json:"city,omitempty"` Continent Continent `json:"continent,omitempty"` Country Country `json:"country,omitempty"` Location Location `json:"location,omitempty"` Postal Postal `json:"postal,omitempty"` RegisteredCountry RegisteredCountry `json:"registered_country,omitempty"` RepresentedCountry RepresentedCountry `json:"represented_country,omitempty"` Subdivisions []Subdivision `json:"subdivisions,omitempty"` Traits Traits `json:"traits,omitempty"` MaxMind MaxMind `json:"maxmind,omitempty"` }
type Subdivision ¶
type Traits ¶
type Traits struct { AutonomousSystemNumber int `json:"autonomous_system_number,omitempty"` AutonomousSystemOrganization string `json:"autonomous_system_organization,omitempty"` Domain string `json:"domain,omitempty"` IsAnonymousProxy bool `json:"is_anonymous_proxy,omitempty"` IsSatelliteProvider bool `json:"is_satellite_provider,omitempty"` Isp string `json:"isp,omitempty"` IpAddress string `json:"ip_address,omitempty"` Organization string `json:"organization,omitempty"` UserType string `json:"user_type,omitempty"` }
Click to show internal directories.
Click to hide internal directories.