| 1 |
go work init |
| 2 |
go work use . ./sub |
| 3 |
|
| 4 |
# Verify that the go.mod files for both modules in the workspace are tidy, |
| 5 |
# and add missing go.sum entries as needed. |
| 6 |
|
| 7 |
cp go.mod go.mod.orig |
| 8 |
go mod tidy |
| 9 |
cmp go.mod go.mod.orig |
| 10 |
|
| 11 |
cd sub |
| 12 |
cp go.mod go.mod.orig |
| 13 |
go mod tidy |
| 14 |
cmp go.mod go.mod.orig |
| 15 |
cd .. |
| 16 |
|
| 17 |
go list -m all |
| 18 |
stdout '^rsc\.io/quote v1\.5\.1$' |
| 19 |
stdout '^rsc\.io/sampler v1\.3\.1$' |
| 20 |
|
| 21 |
# Now remove the module dependencies from the module cache. |
| 22 |
# Because one module upgrades a transitive dependency needed by another, |
| 23 |
# listing the modules in the workspace should error out. |
| 24 |
|
| 25 |
go clean -modcache |
| 26 |
env GOPROXY=off |
| 27 |
! go list -m all |
| 28 |
stderr '^go: rsc.io/[email protected]: module lookup disabled by GOPROXY=off$' |
| 29 |
|
| 30 |
-- example.go -- |
| 31 |
package example |
| 32 |
|
| 33 |
import _ "rsc.io/sampler" |
| 34 |
-- go.mod -- |
| 35 |
module example |
| 36 |
|
| 37 |
go 1.19 |
| 38 |
|
| 39 |
require rsc.io/sampler v1.3.0 |
| 40 |
|
| 41 |
require ( |
| 42 |
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect |
| 43 |
rsc.io/testonly v1.0.0 // indirect |
| 44 |
) |
| 45 |
-- sub/go.mod -- |
| 46 |
module example/sub |
| 47 |
|
| 48 |
go 1.19 |
| 49 |
|
| 50 |
require rsc.io/quote v1.5.1 |
| 51 |
|
| 52 |
require ( |
| 53 |
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect |
| 54 |
rsc.io/sampler v1.3.1 // indirect |
| 55 |
) |
| 56 |
-- sub/sub.go -- |
| 57 |
package example |
| 58 |
|
| 59 |
import _ "rsc.io/quote" |