1 go mod initwork ./a ./b
2 cmp go.work go.work.want
5 stderr 'a(\\|/)a.go:4:8: no required module provides package rsc.io/quote; to add it:\n\tcd '$WORK(\\|/)gopath(\\|/)src(\\|/)a'\n\tgo get rsc.io/quote'
8 go env GOMOD # go env GOMOD reports the module in a single module context
9 stdout $GOPATH(\\|/)src(\\|/)a(\\|/)go.mod
12 stdout 'Hello, world.'
14 # And try from a different directory
17 stdout 'Hello, world.'
20 go list all # all includes both modules
21 stdout 'example.com/a'
22 stdout 'example.com/b'
24 # -mod can only be set to readonly in workspace mode
25 go list -mod=readonly all
26 ! go list -mod=mod all
27 stderr '^go: -mod may only be set to readonly when in workspace mode'
28 go list -mod=mod -workfile=off all
30 # Test that duplicates in the directory list return an error
31 cp go.work go.work.backup
32 cp go.work.dup go.work
33 ! go run example.com/b
34 stderr 'reading go.work: path .* appears multiple times in workspace'
35 cp go.work.backup go.work
40 # Test that we don't run into "newRequirements called with unsorted roots"
41 # panic with unsorted main modules.
42 cp go.work.backwards go.work
45 # Test that command-line-arguments work inside and outside modules.
46 # This exercises the code that determines which module command-line-arguments
49 go build -n -workfile=off -o foo foo.go
50 go build -n -o foo foo.go
86 fmt.Println(quote.Hello())
96 import "example.com/a"
104 import "example.com/a"
111 Create this directory so we can cd to
112 it and make sure paths are interpreted
113 relative to the go.work, not the cwd.
120 import "example.com/b/lib"
126 -- go.work.backwards --
139 fmt.Println("Hello, World")