...

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

Documentation: cmd/go/testdata/script

     1# Verifies golang.org/issue/47738.
     2
     3# In this test, the user has rewritten their imports to use rsc.io/quote/v3,
     4# but their go.mod still requires rsc.io/quote@v1.5.2, and they indirectly
     5# require rsc.io/quote@v1.5.1 but don't import anything from it.
     6go list -m -f '{{.Path}}@{{.Version}}{{if .Indirect}} indirect{{end}}' all
     7stdout '^rsc.io/quote@v1.5.2$'
     8! stdout 'rsc.io/quote/v3'
     9go list -e all
    10! stdout '^rsc.io/quote$'
    11
    12# 'go mod tidy' should preserve the requirement on rsc.io/quote but mark it
    13# indirect. This prevents a downgrade to v1.5.1, which could introduce
    14# an ambiguity.
    15go mod tidy
    16go list -m -f '{{.Path}}@{{.Version}}{{if .Indirect}} indirect{{end}}' all
    17stdout '^rsc.io/quote@v1.5.2 indirect$'
    18stdout '^rsc.io/quote/v3@v3.0.0$'
    19
    20-- go.mod --
    21module use
    22
    23go 1.16
    24
    25require (
    26	old-indirect v0.0.0
    27	rsc.io/quote v1.5.2
    28)
    29
    30replace old-indirect v0.0.0 => ./old-indirect
    31-- go.sum --
    32golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:pvCbr/wm8HzDD3fVywevekufpn6tCGPY3spdHeZJEsw=
    33golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
    34rsc.io/quote v1.5.1/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
    35rsc.io/quote v1.5.2 h1:3fEykkD9k7lYzXqCYrwGAf7iNhbk4yCjHmKBN9td4L0=
    36rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
    37rsc.io/sampler v1.3.0 h1:HLGR/BgEtI3r0uymSP/nl2uPLsUnNJX8toRyhfpBTII=
    38rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
    39-- use.go --
    40package use
    41
    42import (
    43	_ "old-indirect/empty"
    44
    45	_ "rsc.io/quote/v3"
    46)
    47-- old-indirect/empty/empty.go --
    48package empty
    49-- old-indirect/go.mod --
    50module old-indirect
    51
    52go 1.16
    53
    54require rsc.io/quote v1.5.1
    55-- old-indirect/go.sum --
    56golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
    57rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
    58rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=

View as plain text