lionsoul2014/ip2region · error

NewV6Config

Error message

NewV6Config: %w

What it means

Go service factory: NewV6Config (open/verify/header/version/cache loading for the v6 xdb) failed; the wrapped cause identifies the failing step, e.g. bad file or version mismatch.

Solutions

  1. Inspect the wrapped cause (verify, header load, version match, cache load)
  2. Point the v6 config at a valid IPv6 xdb database
  3. Regenerate or re-download the v6 xdb and retry
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at binding/golang/main.go:69 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/eec4dc07f961a000. Report an issue: GitHub.

Appendix: source

Thrown at binding/golang/main.go:69

	}
	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)
}

func createSearcher(dbPath string, cachePolicy string) (*xdb.Searcher, error) {
	handle, err := os.OpenFile(dbPath, os.O_RDONLY, 0600)
	if err != nil {
		return nil, fmt.Errorf("open xdb file `%s`: %w", dbPath, err)
	}

	defer handle.Close()

	// verify the xdb file
	// @Note: do NOT call it every time you create a searcher since this will slow down the search response.
	// @see the util.Verify function for details.
	err = xdb.Verify(handle)
	if err != nil {

View on GitHub (pinned to c1a1fc7d59)