{"record":{"id":"a07349606a9c54af","repo":"golang/go","slug":"multiple-meta-tags-match-import-path-q","errorCode":null,"errorMessage":"multiple meta tags match import path %q","messagePattern":"multiple meta tags match import path %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/vcs/vcs.go","lineNumber":1223,"sourceCode":"// An ImportMismatchError is returned if none match.\nfunc matchGoImport(imports []metaImport, importPath string) (metaImport, error) {\n\tmatch := -1\n\n\terrImportMismatch := ImportMismatchError{importPath: importPath}\n\tfor i, im := range imports {\n\t\tif !str.HasPathPrefix(importPath, im.Prefix) {\n\t\t\terrImportMismatch.mismatches = append(errImportMismatch.mismatches, im.Prefix)\n\t\t\tcontinue\n\t\t}\n\n\t\tif match >= 0 {\n\t\t\tif imports[match].VCS == \"mod\" && im.VCS != \"mod\" {\n\t\t\t\t// All the mod entries precede all the non-mod entries.\n\t\t\t\t// We have a mod entry and don't care about the rest,\n\t\t\t\t// matching or not.\n\t\t\t\tbreak\n\t\t\t}\n\t\t\treturn metaImport{}, fmt.Errorf(\"multiple meta tags match import path %q\", importPath)\n\t\t}\n\t\tmatch = i\n\t}\n\n\tif match == -1 {\n\t\treturn metaImport{}, errImportMismatch\n\t}\n\treturn imports[match], nil\n}\n\n// expand rewrites s to replace {k} with match[k] for each key k in match.\nfunc expand(match map[string]string, s string) string {\n\t// We want to replace each match exactly once, and the result of expansion\n\t// must not depend on the iteration order through the map.\n\t// A strings.Replacer has exactly the properties we're looking for.\n\toldNew := make([]string, 0, 2*len(match))\n\tfor k, v := range match {\n\t\toldNew = append(oldNew, \"{\"+k+\"}\", v)","sourceCodeStart":1205,"sourceCodeEnd":1241,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/vcs/vcs.go#L1205-L1241","documentation":"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.","triggerScenarios":"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.","commonSituations":"Vanity server emitting one tag per subpackage instead of one per module root; templating bug producing duplicate tags.","solutions":["Publish a single go-import meta tag per module root with the longest applicable prefix","Remove redundant per-subpackage meta tags"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Reject vanity pages that emit more than one matching non-mod prefix\nfunc oneMatchPerPath(imports []metaImport) error {\n  seen := map[string]int{}\n  for _, im := range imports {\n    if im.VCS == \"mod\" { continue }\n    seen[im.Prefix]++\n  }\n  for p, n := range seen { if n > 1 { return fmt.Errorf(\"duplicate prefix %s\", p) } }\n  return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Emit exactly one go-import tag per module root","Don't template one tag per subpackage"],"tags":["go","modules","vcs","vanity"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}