geolocation

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package geolocation locates a server address through public IP geolocation services, filling in a server's country and city.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GeoLocationResponse

type GeoLocationResponse struct {
	Country     string `json:"country"`
	CountryName string `json:"country_name"`
	Region      string `json:"region"`
	City        string `json:"city"`
	Latitude    string `json:"latitude"`
	Longitude   string `json:"longitude"`
	Loc         string `json:"loc"`
}

GeoLocationResponse represents the geolocation data returned by the API.

func GetRegionByIp

func GetRegionByIp(ctx context.Context, ip string) (*GeoLocationResponse, error)

GetRegionByIp queries the geolocation of an IP address using supported services, trying them in turn until one answers. Cancelling ctx aborts the lookups.

Jump to

Keyboard shortcuts

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