lionsoul2014/ip2region · error

failed to create v6 config: %w

Error message

failed to create v6 config: %w

What it means

Go convenience constructor: building the default v6 config (open, verify, header/version check, vector-index load) failed; the wrapped error identifies the actual failing step.

Source

Thrown at binding/golang/service/ip2region.go:114

	// create v4 config with default config items
	var v4Config *Config
	if v4XdbPath == "" {
		v4Config = nil
	} else {
		v4Config, err = NewV4Config(VIndexCache, v4XdbPath, 20)
		if err != nil {
			return nil, fmt.Errorf("failed to create v4 config: %w", err)
		}
	}

	// create v6 config with default config items
	var v6Config *Config
	if v6XdbPath == "" {
		v6Config = nil
	} else {
		v6Config, err = NewV6Config(VIndexCache, v6XdbPath, 20)
		if err != nil {
			return nil, fmt.Errorf("failed to create v6 config: %w", err)
		}
	}

	return NewIp2Region(v4Config, v6Config)
}

func (ip2r *Ip2Region) Search(ip any) (string, error) {
	var err error
	var ipBytes []byte
	switch v := ip.(type) {
	case string:
		ipBytes, err = xdb.ParseIP(v)
		if err != nil {
			return "", fmt.Errorf("parse ip %s: %w", v, err)
		}
	case []byte:
		ipBytes = v
	default:

View on GitHub (pinned to c1a1fc7d59)

Solutions

  1. Inspect the wrapped cause for the failing step
  2. Ensure the v6 xdb path refers to a valid IPv6 database
  3. Regenerate or re-download the database and retry
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at binding/golang/service/ip2region.go:114 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/858aa4caaaa8641a. Report an issue: GitHub.