diff options
author | Michael Matloob <matloob@golang.org> | 2022-11-16 13:28:32 -0500 |
---|---|---|
committer | Michael Matloob <matloob@golang.org> | 2022-11-18 18:09:53 +0000 |
commit | fd00c14bf1b7057ae301ec82b82efa0ec5ccc9b4 (patch) | |
tree | e9d4a045b5131725fe78dcc73248b4c445667a70 /src/cmd/go/internal/modload/load.go | |
parent | b2faff18ce28edad98303d2c3134dec1331fd7b5 (diff) | |
download | go-fd00c14bf1b7057ae301ec82b82efa0ec5ccc9b4.tar.gz go-fd00c14bf1b7057ae301ec82b82efa0ec5ccc9b4.zip |
cmd/go: replace 'directory .' with 'current directory' in some errors
To make the error clearer
Fixes #56697
Change-Id: Idfb5e8704d1bfc64bd0a09d5b553086d9ba5ac33
Reviewed-on: https://go-review.googlesource.com/c/go/+/451295
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Diffstat (limited to 'src/cmd/go/internal/modload/load.go')
-rw-r--r-- | src/cmd/go/internal/modload/load.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go index d92e2ba7101..e4f6a953205 100644 --- a/src/cmd/go/internal/modload/load.go +++ b/src/cmd/go/internal/modload/load.go @@ -603,13 +603,17 @@ func resolveLocalPackage(ctx context.Context, dir string, rs *Requirements) (str pkg := pathInModuleCache(ctx, absDir, rs) if pkg == "" { + dirstr := fmt.Sprintf("directory %s", base.ShortPath(absDir)) + if dirstr == "directory ." { + dirstr = "current directory" + } if inWorkspaceMode() { if mr := findModuleRoot(absDir); mr != "" { - return "", fmt.Errorf("directory %s is contained in a module that is not one of the workspace modules listed in go.work. You can add the module to the workspace using:\n\tgo work use %s", base.ShortPath(absDir), base.ShortPath(mr)) + return "", fmt.Errorf("%s is contained in a module that is not one of the workspace modules listed in go.work. You can add the module to the workspace using:\n\tgo work use %s", dirstr, base.ShortPath(mr)) } - return "", fmt.Errorf("directory %s outside modules listed in go.work or their selected dependencies", base.ShortPath(absDir)) + return "", fmt.Errorf("%s outside modules listed in go.work or their selected dependencies", dirstr) } - return "", fmt.Errorf("directory %s outside main module or its selected dependencies", base.ShortPath(absDir)) + return "", fmt.Errorf("%s outside main module or its selected dependencies", dirstr) } return pkg, nil } |