location

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	UnitMiles = "mi"
	UnitKm    = "km"
)

Variables

This section is empty.

Functions

func DisplayText

func DisplayText(city, adminArea, country string) string

DisplayText formats city/admin area with a country flag for UI display.

func DisplayTextForInput

func DisplayTextForInput(raw string) (string, bool, error)

DisplayTextForInput resolves raw user input and returns formatted display text.

func DistanceUnitFromPhone

func DistanceUnitFromPhone(phone string) string

DistanceUnitFromPhone returns mi or km based on the phone number region.

func DistanceUnitFromTimezone

func DistanceUnitFromTimezone(timezone string) string

DistanceUnitFromTimezone returns mi or km from an IANA timezone name.

func FindLocation

func FindLocation(text string) (id int, lat, lon float64, ok bool, err error)

FindLocation resolves text to a cached location row id and coordinates.

func FindLocationID

func FindLocationID(text string) (int, bool, error)

FindLocationID looks up a location row ID for user-entered text, resolving via Geoapify and caching when not already stored.

func MilesToKm

func MilesToKm(miles float64) float64

MilesToKm converts statute miles to kilometers.

func NormalizeMileageUnit

func NormalizeMileageUnit(unit string) string

NormalizeMileageUnit returns mi or km; invalid values default to mi.

func ResolveLocation

func ResolveLocation(text string) (lat, lon float64, ok bool, err error)

ResolveLocation looks up lat/lon for user-entered location text, resolving via Geoapify and caching when not already stored.

func ValidMileageUnit

func ValidMileageUnit(unit string) bool

ValidMileageUnit reports whether unit is mi or km.

Types

type LocationResponse

type LocationResponse struct {
	City      string
	AdminArea string
	Country   string
	Latitude  float64
	Longitude float64
}

LocationResponse is the normalized shape stored in locations.

Jump to

Keyboard shortcuts

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