We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 34665c6 commit 36d412fCopy full SHA for 36d412f
src/cmd/go/internal/modload/load.go
@@ -520,9 +520,10 @@ func ImportFromFiles(ctx context.Context, gofiles []string) {
520
// DirImportPath returns the effective import path for dir,
521
// provided it is within the main module, or else returns ".".
522
func DirImportPath(dir string) string {
523
- if modRoot == "" {
+ if !HasModRoot() {
524
return "."
525
}
526
+ LoadModFile(context.TODO())
527
528
if !filepath.IsAbs(dir) {
529
dir = filepath.Join(base.Cwd, dir)
0 commit comments