Skip to content

Commit

Permalink
Merge pull request #1 from visualfc/extpkgerr
Browse files Browse the repository at this point in the history
gopmod: lookupExternPkg error
  • Loading branch information
xushiwei authored Jun 10, 2022
2 parents df967ba + d3d5d45 commit 3c43a68
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion gopmod/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package gopmod

import (
"fmt"
"log"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -130,7 +131,7 @@ func (p *Module) lookupExternPkg(pkgPath string) (pkg *Package, err error) {
return
}
}
err = syscall.ENOENT
err = &MissingError{Path: pkgPath}
return
}

Expand Down Expand Up @@ -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)
}

// -----------------------------------------------------------------------------

0 comments on commit 3c43a68

Please sign in to comment.