lionsoul2014/ip2region · error
NewV4Config: %w
Error message
NewV4Config: %w
What it means
Go service factory: NewV4Config (open/verify header/check ip version/load caches for the v4 xdb) failed and the error is wrapped with this prefix; the underlying cause identifies the actual step that broke.
Source
Thrown at binding/golang/main.go:54
// fmt.Printf("xdbPath=%s\n", xdbPath)
return xdbPath, nil
}
func createService(v4XdbPath string, v4CachePolicy string, v6XdbPath string, v6CachePolicy string) (*service.Ip2Region, error) {
// try to create v4 config
v4CPolicy, err := service.CachePolicyFromName(v4CachePolicy)
if err != nil {
return nil, fmt.Errorf("parse v4 cache policy: %w", err)
}
v4DbPath, err := homedir.Expand(v4XdbPath)
if err != nil {
return nil, fmt.Errorf("Expand(`%s`): %s", v4XdbPath, err)
}
v4Config, err := service.NewV4Config(v4CPolicy, v4DbPath, 1)
if err != nil {
return nil, fmt.Errorf("NewV4Config: %w", err)
}
// try to create v6 config
v6Policy, err := service.CachePolicyFromName(v6CachePolicy)
if err != nil {
return nil, fmt.Errorf("parse v6 cache policy: %w", err)
}
v6DbPath, err := homedir.Expand(v6XdbPath)
if err != nil {
return nil, fmt.Errorf("Expand(`%s`): %s", v6XdbPath, err)
}
v6Config, err := service.NewV6Config(v6Policy, v6DbPath, 1)
if err != nil {
return nil, fmt.Errorf("NewV6Config: %w", err)
}
return service.NewIp2Region(v4Config, v6Config)View on GitHub (pinned to c1a1fc7d59)
Solutions
- Inspect the wrapped error to find the failing step (open, verify, header, version match, cache load)
- Confirm the v4 xdb path points to a valid IPv4 database
- Fix or regenerate the xdb file, then retry service creation
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at binding/golang/main.go:54 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of lionsoul2014/ip2region@c1a1fc7d59 (2026-09-02).
Data as JSON: /api/errors/aa07a88b06eee2aa.
Report an issue: GitHub.