...

Text file src/cmd/go/testdata/script/work_replace_main_module.txt

Documentation: cmd/go/testdata/script

     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
     8go list example.com/dep
     9
    10cp replace_main_module.go.work go.work
    11! go list example.com/dep
    12stderr '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 --
    15go 1.18
    16use (
    17    ./mainmoda
    18    ./mainmodb
    19)
    20replace example.com/mainmoda => ../mainmodareplacement
    21-- go.work --
    22go 1.18
    23use (
    24    ./mainmoda
    25    ./mainmodb
    26)
    27-- mainmoda/go.mod --
    28module example.com/mainmoda
    29
    30go 1.18
    31
    32require example.com/dep v1.0.0
    33replace example.com/dep => ../dep
    34
    35-- dep/go.mod --
    36module example.com/dep
    37-- dep/dep.go --
    38package dep
    39-- mainmodb/go.mod --
    40module example.com/mainmodb
    41go 1.18
    42replace example.com/mainmoda => ../mainmodareplacement
    43-- mainmodareplacement/go.mod --
    44module example.com/mainmoda
    45go 1.18

View as plain text