...

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

Documentation: cmd/go/testdata/script

     1go mod tidy
     2cp go.mod go.mod.orig
     3
     4# If there is no sensible *package* meaning for 'm/p', it should refer
     5# to *module* m/p.
     6
     7go get m/p  # @latest
     8go list -m all
     9stdout '^m/p v0.3.0 '
    10! stdout '^m '
    11
    12cp go.mod.orig go.mod
    13
    14go get m/p@v0.1.0
    15go list -m all
    16stdout '^m/p v0.1.0 '
    17! stdout '^m '
    18
    19# When feasible, the argument 'm/p' in 'go get m/p' refers to *package* m/p,
    20# which is in module m.
    21#
    22# (It only refers to *module* m/p if there is no such package at the
    23# requested version.)
    24
    25go get m/p@v0.2.0
    26go list -m all
    27stdout '^m v0.2.0 '
    28stdout '^m/p v0.1.0 '  # unchanged from the previous case
    29
    30# Repeating the above with module m/p already in the module graph does not
    31# change its meaning.
    32
    33go get m/p@v0.2.0
    34go list -m all
    35stdout '^m v0.2.0 '
    36stdout '^m/p v0.1.0 '
    37
    38-- go.mod --
    39module example.com
    40
    41go 1.16
    42
    43replace (
    44	m v0.1.0 => ./m01
    45	m v0.2.0 => ./m02
    46	m v0.3.0 => ./m03
    47	m/p v0.1.0 => ./mp01
    48	m/p v0.2.0 => ./mp02
    49	m/p v0.3.0 => ./mp03
    50)
    51-- m01/go.mod --
    52module m
    53
    54go 1.16
    55-- m01/README.txt --
    56Module m at v0.1.0 does not yet contain package p.
    57
    58-- m02/go.mod --
    59module m
    60
    61go 1.16
    62
    63require m/p v0.1.0
    64-- m02/p/p.go --
    65// Package p is present in module m, but not module m/p.
    66package p
    67
    68-- m03/go.mod --
    69module m
    70
    71go 1.16
    72
    73require m/p v0.1.0
    74-- m03/README.txt --
    75Module m at v0.3.0 no longer contains package p.
    76
    77-- mv2/go.mod --
    78module m/v2
    79
    80go 1.16
    81-- mv2/README.txt --
    82This module is m/v2. It doesn't actually need to exist,
    83but it explains how module m could plausibly exist
    84and still contain package p at 'latest' even when module
    85m/p also exists.
    86
    87-- mp01/go.mod --
    88module m/p
    89
    90go 1.16
    91-- mp01/README.txt --
    92This module is m/p.
    93Package m/p does not exist in this module.
    94-- mp02/go.mod --
    95module m/p
    96
    97go 1.16
    98-- mp02/README.txt --
    99This module is m/p.
   100Package m/p does not exist in this module.
   101-- mp03/go.mod --
   102module m/p
   103
   104go 1.16
   105-- mp03/README.txt --
   106This module is m/p.
   107Package m/p does not exist in this module.

View as plain text