From 07466fefe641ba728bacc0c674f8cd73db2eb4a5 Mon Sep 17 00:00:00 2001 From: visualfc Date: Wed, 8 Jun 2022 21:57:45 +0800 Subject: [PATCH 1/3] gopmod: lookupExternPkg error --- gopmod/module.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gopmod/module.go b/gopmod/module.go index 58e430e..28e2fd0 100644 --- a/gopmod/module.go +++ b/gopmod/module.go @@ -17,6 +17,7 @@ package gopmod import ( + "fmt" "log" "path/filepath" "runtime" @@ -130,7 +131,8 @@ func (p *Module) lookupExternPkg(pkgPath string) (pkg *Package, err error) { return } } - err = syscall.ENOENT + err = fmt.Errorf(`no required module provides package %v; to add it: + go get %v`, pkgPath, pkgPath) return } From d3dfb6952ce28511edf634214a87c06b4391015b Mon Sep 17 00:00:00 2001 From: visualfc Date: Thu, 9 Jun 2022 14:17:24 +0800 Subject: [PATCH 2/3] mod: MissingPkgError --- gopmod/module.go | 4 +--- mod.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gopmod/module.go b/gopmod/module.go index 28e2fd0..9a5e46f 100644 --- a/gopmod/module.go +++ b/gopmod/module.go @@ -17,7 +17,6 @@ package gopmod import ( - "fmt" "log" "path/filepath" "runtime" @@ -131,8 +130,7 @@ func (p *Module) lookupExternPkg(pkgPath string) (pkg *Package, err error) { return } } - err = fmt.Errorf(`no required module provides package %v; to add it: - go get %v`, pkgPath, pkgPath) + err = &mod.MissingPkgError{Path: pkgPath} return } diff --git a/mod.go b/mod.go index 17ff88e..cb0225c 100644 --- a/mod.go +++ b/mod.go @@ -17,6 +17,7 @@ package mod import ( + "fmt" "os" "path/filepath" "strings" @@ -68,4 +69,13 @@ func GOMOD(dir string) (file string, err error) { return GOPMOD(dir, GoModOnly) } +type MissingPkgError struct { + Path string +} + +func (e *MissingPkgError) Error() string { + return fmt.Sprintf(`no required module provides package %v; to add it: + go get %v`, e.Path, e.Path) +} + // ----------------------------------------------------------------------------- From d3d5d45ee1c381005fc93a9d51583eec54637dec Mon Sep 17 00:00:00 2001 From: visualfc Date: Fri, 10 Jun 2022 07:34:31 +0800 Subject: [PATCH 3/3] mod.MissingPkgError => gopmod.MissingError --- gopmod/module.go | 12 +++++++++++- mod.go | 10 ---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gopmod/module.go b/gopmod/module.go index 9a5e46f..1fe3007 100644 --- a/gopmod/module.go +++ b/gopmod/module.go @@ -17,6 +17,7 @@ package gopmod import ( + "fmt" "log" "path/filepath" "runtime" @@ -130,7 +131,7 @@ func (p *Module) lookupExternPkg(pkgPath string) (pkg *Package, err error) { return } } - err = &mod.MissingPkgError{Path: pkgPath} + err = &MissingError{Path: pkgPath} return } @@ -210,4 +211,13 @@ func loadModFrom(mod module.Version, mode mod.Mode) (p *Module, err error) { return Load(dir, mode) } +type MissingError struct { + Path string +} + +func (e *MissingError) Error() string { + return fmt.Sprintf(`no required module provides package %v; to add it: + gop get %v`, e.Path, e.Path) +} + // ----------------------------------------------------------------------------- diff --git a/mod.go b/mod.go index cb0225c..17ff88e 100644 --- a/mod.go +++ b/mod.go @@ -17,7 +17,6 @@ package mod import ( - "fmt" "os" "path/filepath" "strings" @@ -69,13 +68,4 @@ func GOMOD(dir string) (file string, err error) { return GOPMOD(dir, GoModOnly) } -type MissingPkgError struct { - Path string -} - -func (e *MissingPkgError) Error() string { - return fmt.Sprintf(`no required module provides package %v; to add it: - go get %v`, e.Path, e.Path) -} - // -----------------------------------------------------------------------------