1
0
mirror of https://github.com/golang/go synced 2024-11-22 03:44:39 -07:00

Add a more specific error message when searching for a module that has no source .go files

This commit is contained in:
Steven Chu 2022-10-28 20:21:10 -07:00
parent c87e69c2b4
commit 4f1be5dfa7
2 changed files with 12 additions and 3 deletions

View File

@ -27,7 +27,8 @@ var importTests = []struct {
},
{
path: "golang.org/x/net",
err: `module golang.org/x/net@.* found \(v[01]\.\d+\.\d+\), but does not contain package golang.org/x/net`,
err: "module golang.org/x/net@.* found \(v[01]\.\d+\.\d+\), but does not contain package golang.org/x/net... " +
"no go files found, are you sure you have the correct import path?",
},
{
path: "golang.org/x/text",

View File

@ -996,9 +996,17 @@ func (e *PackageNotInModuleError) Error() string {
}
if strings.Contains(e.Pattern, "...") {
return fmt.Sprintf("module %s@%s found%s, but does not contain packages matching %s", e.Mod.Path, e.Query, found, e.Pattern)
return fmt.Sprintf(
"module %s@%s found%s, but does not contain packages matching %s... "+
"no go files found, are you sure you have the correct import path?",
e.Mod.Path, e.Query, found, e.Pattern,
)
}
return fmt.Sprintf("module %s@%s found%s, but does not contain package %s", e.Mod.Path, e.Query, found, e.Pattern)
return fmt.Sprintf(
"module %s@%s found%s, but does not contain package %s... "+
"no go files found, are you sure you have the correct import path?",
e.Mod.Path, e.Query, found, e.Pattern,
)
}
func (e *PackageNotInModuleError) ImportPath() string {