package geoip import ( "os" "testing" ) func TestLookupWithConfiguredDatabase(t *testing.T) { path := os.Getenv("GEOIP_TEST_DB") if path == "" { t.Skip("未设置 GEOIP_TEST_DB") } if err := Init(path); err != nil { t.Fatal(err) } defer Close() location, ok := Lookup("8.8.8.8") if !ok || location.Country == "" { t.Fatalf("GeoIP 查询失败: %+v ok=%v", location, ok) } }