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

     1  env GO111MODULE=on
     2  
     3  # 'mod download' should download the module to the cache.
     4  go mod download rsc.io/quote@v1.5.0
     5  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
     6  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
     7  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
     8  
     9  # '-n' should print commands but not actually execute them.
    10  go clean -modcache -n
    11  stdout '^rm -rf .*pkg.mod$'
    12  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
    13  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
    14  exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
    15  
    16  # 'go clean -modcache' should actually delete the files.
    17  go clean -modcache
    18  ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.info
    19  ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.mod
    20  ! exists $GOPATH/pkg/mod/cache/download/rsc.io/quote/@v/v1.5.0.zip
    21  
    22  # 'go clean -r -modcache' should clean only the dependencies that are within the
    23  # main module.
    24  # BUG(golang.org/issue/28680): Today, it cleans across module boundaries.
    25  cd r
    26  exists ./test.out
    27  exists ../replaced/test.out
    28  go clean -r -modcache
    29  ! exists ./test.out
    30  ! exists ../replaced/test.out  # BUG: should still exist
    31  
    32  # 'go clean -modcache' should not download anything before cleaning.
    33  go mod edit -require rsc.io/quote@v1.99999999.0-not-a-real-version
    34  go clean -modcache
    35  ! stderr 'finding rsc.io'
    36  go mod edit -droprequire rsc.io/quote
    37  
    38  ! go clean -modcache m
    39  stderr 'go: clean -modcache cannot be used with package arguments'
    40  
    41  -- go.mod --
    42  module m
    43  -- m.go --
    44  package m
    45  
    46  -- r/go.mod --
    47  module example.com/r
    48  require example.com/r/replaced v0.0.0
    49  replace example.com/r/replaced => ../replaced
    50  -- r/r.go --
    51  package r
    52  import _ "example.com/r/replaced"
    53  -- r/test.out --
    54  DELETE ME
    55  
    56  -- replaced/go.mod --
    57  module example.com/r/replaced
    58  -- replaced/replaced.go --
    59  package replaced
    60  -- replaced/test.out --
    61  DO NOT DELETE
    62  

View as plain text