Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 21c40aa

Browse files
authored
gps: ignore "mod" VCS type in parseMetaGoImports
Apply the same change as in golang.org/cl/175219 to this copy of the parseMetaGoImports function, helping keep them in sync. The "mod" type is not a real version control system (VCS), it applies only when in module mode. Skip it and continue to consider only real VCS types. This resolves parseMetaGoImports returning a "multiple meta tags match import path" error on packages that offer go-import meta tags with both a true VCS and the "mod" type. Reference: https://golang.org/cmd/go/#hdr-Remote_import_paths Fixes #2151
1 parent 66ec1e8 commit 21c40aa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

gps/discovery.go

+7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ type metaImport struct {
3535

3636
// parseMetaGoImports returns meta imports from the HTML in r.
3737
// Parsing ends at the end of the <head> section or the beginning of the <body>.
38+
//
39+
// This copy of cmd/go/internal/vcs.parseMetaGoImports always operates
40+
// in IgnoreMod ModuleMode.
3841
func parseMetaGoImports(r io.Reader) (imports []metaImport, err error) {
3942
d := xml.NewDecoder(r)
4043
d.CharsetReader = charsetReader
@@ -62,6 +65,10 @@ func parseMetaGoImports(r io.Reader) (imports []metaImport, err error) {
6265
continue
6366
}
6467
if f := strings.Fields(attrValue(e.Attr, "content")); len(f) == 3 {
68+
// Ignore VCS type "mod", which is applicable only in module mode.
69+
if f[1] == "mod" {
70+
continue
71+
}
6572
imports = append(imports, metaImport{
6673
Prefix: f[0],
6774
VCS: f[1],

0 commit comments

Comments
 (0)