diff options
author | Michael Matloob <matloob@golang.org> | 2021-06-08 17:07:10 -0400 |
---|---|---|
committer | Michael Matloob <matloob@golang.org> | 2021-07-26 21:12:11 +0000 |
commit | 7ce257147fe0ab3413c8e36909c2408c833efdb8 (patch) | |
tree | 7604e92d876b3c1ed69a27659f93fa507e21d151 /src/cmd/go/testdata/script/work.txt | |
parent | 3cd15e02ed26d86556cb59ff509a1f5a08bca29e (diff) | |
download | go-7ce257147fe0ab3413c8e36909c2408c833efdb8.tar.gz go-7ce257147fe0ab3413c8e36909c2408c833efdb8.zip |
[dev.cmdgo] cmd/go: add the workspace mode
This change adds the outline of the implementation of the workspace mode.
The go command will now locate go.work files, and read them to determine
which modules are in the workspace. It will then put those modules in
the root of the workspace when building the build list. It supports
building, running, testing, and listing in workspaces. There are still
many TODOs for undone work and other changes to fix certain cases. Some
of these undone parts include: replaces and go.work.sum files, as well
as go mod {test,why,verify}, excludes in workspaces, updating work files
to include module names in comments and setting the GOWORK variable.
For #45713
Change-Id: I72716af7a300a2896087fc8a79c04e951d248278
Reviewed-on: https://go-review.googlesource.com/c/go/+/334934
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/testdata/script/work.txt')
-rw-r--r-- | src/cmd/go/testdata/script/work.txt | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/cmd/go/testdata/script/work.txt b/src/cmd/go/testdata/script/work.txt new file mode 100644 index 0000000000..f2b51ca629 --- /dev/null +++ b/src/cmd/go/testdata/script/work.txt @@ -0,0 +1,71 @@ +go run example.com/b +stdout 'Hello from module A' + +# And try from a different directory +cd c +go run example.com/b +stdout 'Hello from module A' +cd $GOPATH/src + +go list all # all includes both modules +stdout 'example.com/a' +stdout 'example.com/b' + +# -mod can't be set in workspace mode, even to readonly +! go list -mod=readonly all +stderr '^go: -mod can''t be set explicitly' +go list -mod=readonly -workfile=off all + +# Test that duplicates in the directory list return an error +cp go.work go.work.backup +cp go.work.dup go.work +! go run example.com/b +stderr 'reading go.work: path .* appears multiple times in workspace' +cp go.work.backup go.work + +-- go.work.dup -- +go 1.17 + +directory ( + a + b + ../src/a +) +-- go.work -- +go 1.17 + +directory ( + ./a + ./b +) + +-- a/go.mod -- + +module example.com/a + +-- a/a.go -- +package a + +import "fmt" + +func HelloFromA() { + fmt.Println("Hello from module A") +} + +-- b/go.mod -- + +module example.com/b + +-- b/main.go -- +package main + +import "example.com/a" + +func main() { + a.HelloFromA() +} + +-- c/README -- +Create this directory so we can cd to +it and make sure paths are interpreted +relative to the go.work, not the cwd. |