updated

This commit is contained in:
landaiqing
2024-11-14 01:58:20 +08:00
parent c95d5fc041
commit 3b8e3df27a
83 changed files with 172212 additions and 343 deletions

View File

@@ -0,0 +1,27 @@
package ip2region
import (
"os"
"path/filepath"
"github.com/lionsoul2014/ip2region/binding/golang/xdb"
)
// NewIP2Region creates a new IP2Region searcher instance.
func NewIP2Region() *xdb.Searcher {
cwd, err := os.Getwd()
if err != nil {
panic(err)
}
dbPath := filepath.Join(cwd, "resources/ip2region", "ip2region.xdb")
cBuff, err := xdb.LoadContentFromFile(dbPath)
if err != nil {
panic(err)
}
searcher, err := xdb.NewWithBuffer(cBuff)
if err != nil {
panic(err)
return nil
}
return searcher
}