1 # Ensure that replaces of the main module in workspace modules
2 # are ignored, and replaces in the go.work file are disallowed.
3 # This tests against an issue where requirements of the
4 # main module were being ignored because the main module
5 # was replaced in a transitive dependency with another
6 # version.
7
8 go list example.com/dep
9
10 cp replace_main_module.go.work go.work
11 ! go list example.com/dep
12 stderr 'go: workspace module example.com/mainmoda is replaced at all versions in the go.work file. To fix, remove the replacement from the go.work file or specify the version at which to replace the module.'
13
14 -- replace_main_module.go.work --
15 go 1.18
16 use (
17 ./mainmoda
18 ./mainmodb
19 )
20 replace example.com/mainmoda => ../mainmodareplacement
21 -- go.work --
22 go 1.18
23 use (
24 ./mainmoda
25 ./mainmodb
26 )
27 -- mainmoda/go.mod --
28 module example.com/mainmoda
29
30 go 1.18
31
32 require example.com/dep v1.0.0
33 replace example.com/dep => ../dep
34
35 -- dep/go.mod --
36 module example.com/dep
37 -- dep/dep.go --
38 package dep
39 -- mainmodb/go.mod --
40 module example.com/mainmodb
41 go 1.18
42 replace example.com/mainmoda => ../mainmodareplacement
43 -- mainmodareplacement/go.mod --
44 module example.com/mainmoda
45 go 1.18
View as plain text