geolite2

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package geolite2 returns the city or country location of an IP address. The IP region data is from GeoLite2 created by MaxMind, available from https://www.maxmind.com. © Ben Garrett https://github.com/bengarrett/myip

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrInvalid = errors.New("ip address is an invalid textual representation")

Functions

func City

func City(ip string) (string, error)
Example
package main

import (
	"fmt"
	"log"

	_ "embed"
	"github.com/bengarrett/myip/pkg/geolite2"
)

func main() {
	s, err := geolite2.City("93.184.216.34")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(s)
}
Output:

Norwell, United States

func Country

func Country(ip string) (string, error)
Example
package main

import (
	"fmt"
	"log"

	_ "embed"
	"github.com/bengarrett/myip/pkg/geolite2"
)

func main() {
	s, err := geolite2.Country("93.184.216.34")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(s)
}
Output:

United States

Types

This section is empty.

Jump to

Keyboard shortcuts

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