location

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalid for location.
	ErrInvalid = errors.New("invalid")

	// ErrNotFound for location.
	ErrNotFound = errors.New("not found")
)
View Source
var (
	// Module for fx.
	Module = fx.Options(
		fx.Provide(ip.NewDB),
		fx.Provide(country.NewQuery),
		fx.Provide(New),
		fx.Provide(orb.NewRTree),
	)
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Continent continent.Config `yaml:"continent"`
	IP        ip.Config        `yaml:"ip"`
}

Config for location.

type Location

type Location struct {
	// contains filtered or unexported fields
}

Location will find the country and continent by different criteria.

func New

func New(db *ip2location.DB, query *gountries.Query, tree *rtree.Generic[*orb.Node]) *Location

New location.

func (*Location) GetByIP

func (l *Location) GetByIP(ctx context.Context, ipa string) (string, string, error)

GetByIP a country and continent, otherwise error.

func (*Location) GetByLatLng added in v1.4.0

func (l *Location) GetByLatLng(ctx context.Context, lat, lng float64) (string, string, error)

GetByLatLng a country and continent, otherwise error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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