golang/go · error
multiple meta tags match import path %q
Error message
multiple meta tags match import path %q
What it means
In matchGoImport, two (or more) non-'mod' meta-import entries both have prefixes that cover the requested import path. mod entries sort first and short-circuit, so this only fires for genuine duplicates among non-mod VCS entries.
Source
Thrown at src/cmd/go/internal/vcs/vcs.go:1223
// An ImportMismatchError is returned if none match.
func matchGoImport(imports []metaImport, importPath string) (metaImport, error) {
match := -1
errImportMismatch := ImportMismatchError{importPath: importPath}
for i, im := range imports {
if !str.HasPathPrefix(importPath, im.Prefix) {
errImportMismatch.mismatches = append(errImportMismatch.mismatches, im.Prefix)
continue
}
if match >= 0 {
if imports[match].VCS == "mod" && im.VCS != "mod" {
// All the mod entries precede all the non-mod entries.
// We have a mod entry and don't care about the rest,
// matching or not.
break
}
return metaImport{}, fmt.Errorf("multiple meta tags match import path %q", importPath)
}
match = i
}
if match == -1 {
return metaImport{}, errImportMismatch
}
return imports[match], nil
}
// expand rewrites s to replace {k} with match[k] for each key k in match.
func expand(match map[string]string, s string) string {
// We want to replace each match exactly once, and the result of expansion
// must not depend on the iteration order through the map.
// A strings.Replacer has exactly the properties we're looking for.
oldNew := make([]string, 0, 2*len(match))
for k, v := range match {
oldNew = append(oldNew, "{"+k+"}", v)View on GitHub (pinned to b6b368adc5)
Solutions
- Publish a single go-import meta tag per module root with the longest applicable prefix
- Remove redundant per-subpackage meta tags
Defensive patterns
Strategy: validation
Validate before calling
// Reject vanity pages that emit more than one matching non-mod prefix
func oneMatchPerPath(imports []metaImport) error {
seen := map[string]int{}
for _, im := range imports {
if im.VCS == "mod" { continue }
seen[im.Prefix]++
}
for p, n := range seen { if n > 1 { return fmt.Errorf("duplicate prefix %s", p) } }
return nil
} Prevention
- Emit exactly one go-import tag per module root
- Don't template one tag per subpackage
When it happens
Trigger: Page lists e.g. 'example.com/foo git ...' and 'example.com/foo/bar git ...' and the import path is 'example.com/foo/bar' — both prefixes match.
Common situations: Vanity server emitting one tag per subpackage instead of one per module root; templating bug producing duplicate tags.
Related errors
- parse %s: %v
- parse %s: no go-import meta tags (%s)
- %s and %s disagree about go-import for %s
- %s: invalid subdirectory %q: %v
- %s: invalid repo root %q: %v
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/a07349606a9c54af.
Report an issue: GitHub.