geoip

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

README

Geoip Module

The geoip module provides a simple way to determine the geographical location of the system executing the code. This includes details such as longitude, latitude, country, city, and continent.

Features

  • Failover Mechanism: The module attempts to fetch location data from multiple services to ensure high availability. If one URL fails, it logs the error and retries with the next URL.
  • Structured Location Data: Returns structured data in a Location struct for easy integration.
type Location struct {
	Longitude   float64 `json:"longitude"`
	Latitude    float64 `json:"latitude"`
	Continent   string  `json:"continent"`
	Country     string  `json:"country_name"`
	CountryCode string  `json:"country_code"`
	City        string  `json:"city_name"`
}

Usage

The module provides a single exported function: Fetch.

The Fetch function retrieves the geographical location of the system calling the function.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Location

type Location struct {
	Longitude   float64 `json:"longitude"`
	Latitude    float64 `json:"latitude"`
	Continent   string  `json:"continent"`
	Country     string  `json:"country_name"`
	CountryCode string  `json:"country_code"`
	City        string  `json:"city_name"`
}

Location holds the result of a geoip request

func Fetch

func Fetch() (Location, error)

Fetch retrieves the location of the system calling this function

Jump to

Keyboard shortcuts

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