func init() { // replace iplocFilePath to your iploc.dat path iplocFilePath, _ := filepath.Abs("src/github.com/slene/iploc/iploc.dat") // simple set a true param can preload all ipinfo // need allocate more memory > 30M // and speed can grow up about 40 percent than not preload iploc.IpLocInit(iplocFilePath, true) // read iploc.dat into memory, not preload // iploc.IpLocInit(iplocFilePath) }
func init() { pwd, _ := os.Getwd() iplocFilePath, _ := filepath.Abs(filepath.Join(pwd, "src/github.com/slene/iploc/iploc.dat")) iploc.IpLocInit(iplocFilePath) }