geo

package
v1.29.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package geo provides geo-location utilities for AppEngine

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Location

type Location struct {
	Country      string    `datastore:"country"`       // ISO 3166-1 alpha-2 country code (e.g., "US")
	Region       string    `datastore:"region"`        // Region/state (e.g., "ca" for California)
	City         string    `datastore:"city"`          // City name
	CityLatLong  string    `datastore:"city_latlong"`  // Latitude,longitude
	DetectedAt   time.Time `datastore:"detected_at"`   // When this location was detected
	DetectedFrom string    `datastore:"detected_from"` // "session" or "signup"
}

Location represents geographic information from AppEngine headers

func ExtractFromRequest

func ExtractFromRequest(r *http.Request) *Location

ExtractFromRequest extracts geo-location from AppEngine headers AppEngine automatically adds these headers based on the client's IP address

func (*Location) GetCountryName

func (l *Location) GetCountryName() string

GetCountryName returns a human-readable country name This is a simple implementation - for production you may want a full lookup table

func (*Location) GetDisplayString

func (l *Location) GetDisplayString() string

GetDisplayString returns a formatted location string for display

func (*Location) IsUS

func (l *Location) IsUS() bool

IsUS checks if the location is in the United States

func (*Location) IsValid

func (l *Location) IsValid() bool

IsValid checks if location data was successfully extracted

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL