ip2location

package module
v0.0.0-...-9ca7428 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: MIT Imports: 2 Imported by: 3

README

命令行

go get github.com/techxmind/ip2location/cmd/ip2loc

ip2loc -h
ip2loc 113.143.136.174 123.15.145.134

示例

import (
    "fmt"

    "github.com/techxmind/ip2location"
)

ip := "123.15.145.134"
if loc, err := ip2location.Get(ip); err != nil {
    fmt.Print(err)
} else {
    fmt.Printf(
        "country: %s\nprovince: %s\ncity: %s\ngeo id:%s\nregion id:%s\n",
        loc.Country,
        loc.Province,
        loc.City,
        loc.GeoID,
        loc.ChinaRegionID,
    )
}

Documentation

Overview

Package ip2location get geo location from given ip address

ip data comes from www.ipcaa.org

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidIp = errors.New("invalid ip address")
	ErrNotFound  = errors.New("ip location not found")
)

Functions

This section is empty.

Types

type Location

type Location struct {
	Country       string
	Province      string
	City          string
	GeoID         string
	ChinaRegionID string
}

func Get

func Get(ip string) (loc *Location, err error)

Get get geo location from ip address

Directories

Path Synopsis
cmd
ip2loc command

Jump to

Keyboard shortcuts

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