Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go/internal/modload: reject empty go.mod files
Don't add a module declaration to a go.mod file when loading a module. Require a user to call go mod init or to add the module declaration themselves. Fixes #35070 Change-Id: If5543580d3c1cfee1fc528eb853b872c4173ca82 Reviewed-on: https://go-review.googlesource.com/c/go/+/234107 Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
- Loading branch information
Showing
3 changed files
with
20 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Test that mod files with missing paths produce an error. | ||
|
||
# Test that go list fails on a go.mod with no module declaration. | ||
cd $WORK/gopath/src/mod | ||
! go list . | ||
stderr '^go: no module declaration in go.mod.\n\tRun ''go mod edit -module=example.com/mod'' to specify the module path.$' | ||
|
||
-- mod/go.mod -- | ||
|
||
-- mod/foo.go -- | ||
package foo | ||
|