Skip to content

A ip-database library for golang. Find a information of an IP address including country,province,city,region,street and network provider.

Notifications You must be signed in to change notification settings

johntech-o/iphelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

iphelper

A ip-database library for golang. Find a information of an IP address including country,province,city,region,street and network provider.

u can find example in the iphelper_test.go

// init use the ip.dat file

var store = NewIpStore("ip.dat")

// get geo info of ip address

geo, e := store.GetGeoByIp("101.52.255.200")

// map[country:中国 province:北京市 city:北京市 zone:朝阳区 location:未知 operator:电信 areacode:20003000100370101]

fmt.Println(geo)

// get areacode of ip address

code, e := store.GetGeocodeByIp("101.52.255.200")

// 20003000100370101

fmt.Println(code)

// get the geo info of areacode

// u can save the areacode to user`s session

// get the geo info by areacode is more fast than by ip address

codeGeo := store.GetGeoByGeocode(code)

// map[country:中国 province:上海市 city:上海市 zone:未知 location:未知 operator:未知 areacode:20017009000000100]

fmt.Println(codeGeo)

// get all the area info of the ip databases

table := store.GetMetaTable()

for typ, areas := range table {
	fmt.Println(typ, len(areas), areas)
	fmt.Println("--------------------")
}

About

A ip-database library for golang. Find a information of an IP address including country,province,city,region,street and network provider.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages