aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/modload/import.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2021-03-23 00:26:39 -0400
committerBryan C. Mills <bcmills@google.com>2021-03-25 03:17:51 +0000
commitadb037d67ad46491bb0e9c2a09b56e89dd8a3617 (patch)
tree3af2b98a6e10490e8e04a403a1287743afd08c78 /src/cmd/go/internal/modload/import.go
parent954879d6d19175a5f0066c0ac0df0edda7f731b3 (diff)
downloadgo-adb037d67ad46491bb0e9c2a09b56e89dd8a3617.tar.gz
go-adb037d67ad46491bb0e9c2a09b56e89dd8a3617.zip
cmd/go: attribute direct imports from indirect dependencies to the importing package
For #36460 Updates #40775 Change-Id: I833ee8ee733151aafcff508bf91d0e6e37c50032 Reviewed-on: https://go-review.googlesource.com/c/go/+/303869 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/modload/import.go')
-rw-r--r--src/cmd/go/internal/modload/import.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/cmd/go/internal/modload/import.go b/src/cmd/go/internal/modload/import.go
index 508db2f247..1d321bb24b 100644
--- a/src/cmd/go/internal/modload/import.go
+++ b/src/cmd/go/internal/modload/import.go
@@ -128,6 +128,23 @@ func (e *AmbiguousImportError) Error() string {
return buf.String()
}
+// A DirectImportFromImplicitDependencyError indicates a package directly
+// imported by a package or test in the main module that is satisfied by a
+// dependency that is not explicit in the main module's go.mod file.
+type DirectImportFromImplicitDependencyError struct {
+ ImporterPath string
+ ImportedPath string
+ Module module.Version
+}
+
+func (e *DirectImportFromImplicitDependencyError) Error() string {
+ return fmt.Sprintf("package %s imports %s from implicitly required module; to add missing requirements, run:\n\tgo get %s@%s", e.ImporterPath, e.ImportedPath, e.Module.Path, e.Module.Version)
+}
+
+func (e *DirectImportFromImplicitDependencyError) ImportPath() string {
+ return e.ImporterPath
+}
+
// ImportMissingSumError is reported in readonly mode when we need to check
// if a module contains a package, but we don't have a sum for its .zip file.
// We might need sums for multiple modules to verify the package is unique.