github.com/zxy12/go_duplicate_112_new@v0.0.0-20200807091221-747231827200/src/cmd/go/testdata/script/mod_readonly.txt (about)

     1  env GO111MODULE=on
     2  
     3  # -mod=readonly must not resolve missing modules nor update go.mod
     4  #
     5  # TODO(bcmills): 'go list' should suffice, but today it does not fail due to
     6  # unresolved imports. When that is fixed, use 'go list' instead of 'go list all'.
     7  env GOFLAGS=-mod=readonly
     8  go mod edit -fmt
     9  cp go.mod go.mod.empty
    10  ! go list all
    11  stderr 'import lookup disabled by -mod=readonly'
    12  cmp go.mod go.mod.empty
    13  
    14  # update go.mod - go get allowed
    15  go get rsc.io/quote
    16  grep rsc.io/quote go.mod
    17  
    18  # update go.mod - go mod tidy allowed
    19  cp go.mod.empty go.mod
    20  go mod tidy
    21  
    22  # -mod=readonly must succeed once go.mod is up-to-date...
    23  go list
    24  
    25  # ... even if it needs downloads
    26  go clean -modcache
    27  go list
    28  
    29  # -mod=readonly should reject inconsistent go.mod files
    30  # (ones that would be rewritten).
    31  go mod edit -require rsc.io/sampler@v1.2.0
    32  cp go.mod go.mod.inconsistent
    33  ! go list
    34  stderr 'go: updates to go.mod needed, disabled by -mod=readonly'
    35  cmp go.mod go.mod.inconsistent
    36  
    37  -- go.mod --
    38  module m
    39  
    40  go 1.20
    41  
    42  -- x.go --
    43  package x
    44  import _ "rsc.io/quote"