blob: 5ae74a4348745b5f9e5adbd16277392609328722 [file] [log] [blame]
env GO111MODULE=on
# -mod=readonly must not resolve missing modules nor update go.mod
env GOFLAGS=-mod=readonly
go mod edit -fmt
cp go.mod go.mod.empty
! go list
stderr 'import lookup disabled by -mod=readonly'
cmp go.mod go.mod.empty
# update go.mod - go get allowed
go get rsc.io/quote
grep rsc.io/quote go.mod
# update go.mod - go mod tidy allowed
cp go.mod.empty go.mod
go mod tidy
# -mod=readonly must succeed once go.mod is up-to-date...
go list
# ... even if it needs downloads
go clean -modcache
go list
# -mod=readonly should reject inconsistent go.mod files
# (ones that would be rewritten).
go mod edit -require rsc.io/sampler@v1.2.0
cp go.mod go.mod.inconsistent
! go list
stderr 'go: updates to go.mod needed, disabled by -mod=readonly'
cmp go.mod go.mod.inconsistent
-- go.mod --
module m
-- x.go --
package x
import _ "rsc.io/quote"