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

1
2
3
4
5
6
7
8
9
10
11
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

1
2
go test
go test -bench=Search

Example

Get the parser

1
go get github.com/0x333333/iplocation.go

Sample

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import (
"fmt"
"github.com/0x333333/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)
}
}
}