aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/work.txt
diff options
context:
space:
mode:
authorMichael Matloob <matloob@golang.org>2021-06-28 15:48:03 -0400
committerMichael Matloob <matloob@golang.org>2021-07-28 18:11:31 +0000
commit288a83dcffef18514e8c01f0ca2053c6be185305 (patch)
treea77f77dbc118f01f1c199ca45d6bf5598ca560fa /src/cmd/go/testdata/script/work.txt
parent2c8acf63c233430f8fb48f37c6ec54a29bd53c28 (diff)
downloadgo-288a83dcffef18514e8c01f0ca2053c6be185305.tar.gz
go-288a83dcffef18514e8c01f0ca2053c6be185305.zip
[dev.cmdgo] cmd/go: maintain a go.work.sum file
This change causes the go command to maintain a separate go.work.sum file when in workspace mode rather than using the go.sum files from the individual modules. This isn't quite what the proposal spec specifies, which is that the sums that don't exist in any of the workspace modules are added to go.work.sum rather than the necessary sums. That will be done in a future change. Change-Id: I528b9b153a93a4cd67c5af471ad6d5bd3628578b Reviewed-on: https://go-review.googlesource.com/c/go/+/334939 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.txt46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/cmd/go/testdata/script/work.txt b/src/cmd/go/testdata/script/work.txt
index c68ca89a76..0d820fffc2 100644
--- a/src/cmd/go/testdata/script/work.txt
+++ b/src/cmd/go/testdata/script/work.txt
@@ -1,13 +1,20 @@
go mod initwork ./a ./b
cmp go.work go.work.want
+! go run example.com/b
+stderr 'a(\\|/)a.go:4:8: no required module provides package rsc.io/quote; to add it:\n\tgo get rsc.io/quote'
+cd a
+go get rsc.io/quote
+go env GOMOD # go env GOMOD reports the module in a single module context
+stdout $GOPATH(\\|/)src(\\|/)a(\\|/)go.mod
+cd ..
go run example.com/b
-stdout 'Hello from module A'
+stdout 'Hello, world.'
# And try from a different directory
cd c
-go run example.com/b
-stdout 'Hello from module A'
+go run example.com/b
+stdout 'Hello, world.'
cd $GOPATH/src
go list all # all includes both modules
@@ -26,6 +33,9 @@ cp go.work.dup go.work
stderr 'reading go.work: path .* appears multiple times in workspace'
cp go.work.backup go.work
+cp go.work.d go.work
+go run example.com/d
+
-- go.work.dup --
go 1.17
@@ -41,6 +51,14 @@ directory (
./a
./b
)
+-- go.work.d --
+go 1.17
+
+directory (
+ a
+ b
+ d
+)
-- a/go.mod --
module example.com/a
@@ -49,9 +67,10 @@ module example.com/a
package a
import "fmt"
+import "rsc.io/quote"
func HelloFromA() {
- fmt.Println("Hello from module A")
+ fmt.Println(quote.Hello())
}
-- b/go.mod --
@@ -66,8 +85,27 @@ import "example.com/a"
func main() {
a.HelloFromA()
}
+-- b/lib/hello.go --
+package lib
+
+import "example.com/a"
+
+func Hello() {
+ 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.
+-- d/go.mod --
+module example.com/d
+
+-- d/main.go --
+package main
+
+import "example.com/b/lib"
+
+func main() {
+ lib.Hello()
+}