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:
parent
c87e69c2b4
commit
4f1be5dfa7
@ -27,7 +27,8 @@ var importTests = []struct {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "golang.org/x/net",
|
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",
|
path: "golang.org/x/text",
|
||||||
|
@ -996,9 +996,17 @@ func (e *PackageNotInModuleError) Error() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(e.Pattern, "...") {
|
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 {
|
func (e *PackageNotInModuleError) ImportPath() string {
|
||||||
|
Loading…
Reference in New Issue
Block a user