An IP-Location Parser Written in GO

Datetime:2016-08-23 05:16:17          Topic: Golang           Share

This parser is targeted to parse a IP dataset, which contains the data mapping like this:

type Information struct {
Continent string
Country string
Province string
City string
Isp string
CountryEn string
CountryCode string
long string
lat string
}

Note, data sample is not included in this repo, you can get it from QQZENG, or you can drop me an email and get a short sample.

This parser is under MIT license .

Test

go test
go test -bench=Search

Example

Get the parser

go get github.com/zp-j/iplocation.go

Sample

import (
"fmt"
"github.com/zp-j/iplocation.go"
)

func main() {
ip := "59.78.23.18"
data := "datafile.dat"

if parser, err := QQLocation.Init(data); err != nil {
if info, errParse := parser.Search(ip); errParse != nil {
fmt.Println(info)
}
}
}




About List