...

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

Documentation: cmd/go/testdata/script

     1# example.net/pkgremoved@v0.1.0 refers to a package.
     2go get example.net/pkgremoved@v0.1.0
     3
     4go list example.net/pkgremoved
     5stdout '^example.net/pkgremoved'
     6
     7cp go.mod go.mod.orig
     8
     9
    10# When we resolve a new dependency on example.net/other,
    11# it will change the meaning of the path "example.net/pkgremoved"
    12# from a package (at v0.1.0) to only a module (at v0.2.0).
    13#
    14# If we simultaneously 'get' that module at the query "patch", the module should
    15# be constrained to the latest patch of its originally-selected version (v0.1.0),
    16# not upgraded to the latest patch of the new transitive dependency.
    17
    18! go get example.net/pkgremoved@patch example.net/other@v0.1.0
    19stderr '^go: example.net/other@v0.1.0 requires example.net/pkgremoved@v0.2.0, not example.net/pkgremoved@patch \(v0.1.1\)$'
    20cmp go.mod.orig go.mod
    21
    22
    23# However, we should be able to patch from a package to a module and vice-versa.
    24
    25# Package to module ...
    26
    27go get example.net/pkgremoved@v0.3.0
    28go list example.net/pkgremoved
    29stdout 'example.net/pkgremoved'
    30
    31go get example.net/pkgremoved@patch
    32! go list example.net/pkgremoved
    33
    34# ... and module to package.
    35
    36go get example.net/pkgremoved@v0.4.0
    37! go list example.net/pkgremoved
    38
    39go get example.net/pkgremoved@patch
    40go list example.net/pkgremoved
    41stdout 'example.net/pkgremoved'
    42
    43
    44-- go.mod --
    45module example
    46
    47go 1.16
    48
    49replace (
    50	example.net/other v0.1.0 => ./other
    51
    52	example.net/pkgremoved v0.1.0 => ./prpkg
    53	example.net/pkgremoved v0.1.1 => ./prpkg
    54
    55	example.net/pkgremoved v0.2.0 => ./prmod
    56	example.net/pkgremoved v0.2.1 => ./prmod
    57
    58	example.net/pkgremoved v0.3.0 => ./prpkg
    59	example.net/pkgremoved v0.3.1 => ./prmod
    60
    61	example.net/pkgremoved v0.4.0 => ./prmod
    62	example.net/pkgremoved v0.4.1 => ./prpkg
    63)
    64-- other/go.mod --
    65module example.net/other
    66
    67go 1.16
    68
    69require example.net/pkgremoved v0.2.0
    70-- other/other.go --
    71package other
    72-- prpkg/go.mod --
    73module example.net/pkgremoved
    74
    75go 1.16
    76-- prpkg/pkgremoved.go --
    77package pkgremoved
    78-- prmod/go.mod --
    79module example.net/pkgremoved
    80-- prmod/README.txt --
    81Package pkgremoved was removed in v0.2.0 and v0.3.1,
    82and added in v0.1.0 and v0.4.1.

View as plain text