golang/go · error

parse %s: %v

Error message

parse %s: %v

What it means

Raised inside matchGoImport when matching the parsed meta imports against the requested import path fails for a reason OTHER than an ImportMismatchError. The %s is the request URL; %v is the underlying match error. The non-mismatch branch typically means multiple/structurally invalid entries short-circuited before mismatch classification.

Source

Thrown at src/cmd/go/internal/vcs/vcs.go:1021

	}
	body := resp.Body
	defer body.Close()
	imports, err := parseMetaGoImports(body, mod)
	if len(imports) == 0 {
		if respErr := resp.Err(); respErr != nil {
			// If the server's status was not OK, prefer to report that instead of
			// an XML parse error.
			return nil, respErr
		}
	}
	if err != nil {
		return nil, fmt.Errorf("parsing %s: %v", importPath, err)
	}
	// Find the matched meta import.
	mmi, err := matchGoImport(imports, importPath)
	if err != nil {
		if _, ok := err.(ImportMismatchError); !ok {
			return nil, fmt.Errorf("parse %s: %v", url, err)
		}
		return nil, fmt.Errorf("parse %s: no go-import meta tags (%s)", resp.URL, err)
	}
	if cfg.BuildV {
		log.Printf("get %q: found meta tag %#v at %s", importPath, mmi, url)
	}
	// If the import was "uni.edu/bob/project", which said the
	// prefix was "uni.edu" and the RepoRoot was "evilroot.com",
	// make sure we don't trust Bob and check out evilroot.com to
	// "uni.edu" yet (possibly overwriting/preempting another
	// non-evil student). Instead, first verify the root and see
	// if it matches Bob's claim.
	if mmi.Prefix != importPath {
		if cfg.BuildV {
			log.Printf("get %q: verifying non-authoritative meta tag", importPath)
		}
		var imports []metaImport
		url, imports, err = metaImportsForPrefix(mmi.Prefix, mod, security)

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Inspect the page's go-import meta tags and ensure exactly one cleanly matches the full import path
  2. Remove duplicate or overlapping meta-import declarations on the vanity server
  3. Re-fetch after correcting the meta tags and clear the module cache
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the meta-import set has exactly one matching prefix
func uniqueMatch(imports []metaImport, importPath string) (metaImport, error) {
  match := -1
  for i, im := range imports {
    if !str.HasPathPrefix(importPath, im.Prefix) { continue }
    if match >= 0 { return metaImport{}, fmt.Errorf("ambiguous: %s and %s", imports[match].Prefix, im.Prefix) }
    match = i
  }
  if match == -1 { return metaImport{}, errors.New("no match") }
  return imports[match], nil
}

Prevention

When it happens

Trigger: The parsed meta-import set causes matchGoImport to return a non-mismatch error (e.g. an internal inconsistency) before the mismatch path is reached.

Common situations: Server lists contradictory or duplicate meta-import lines for overlapping prefixes; legacy vanity server with malformed entries; transient inconsistency between concurrent fetches.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/3aa2122f24b4031f. Report an issue: GitHub.