...

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

Documentation: cmd/go/testdata/script

     1env GO111MODULE=on
     2
     3# golang.org/issue/31248: required modules imposed by dependency versions
     4# older than the selected version must still be taken into account.
     5
     6env GOFLAGS=-mod=readonly
     7
     8# Indirect dependencies required via older-than-selected versions must exist in
     9# the module graph, but do not need to be listed explicitly in the go.mod file
    10# (since they are implied).
    11go mod graph
    12stdout i@v0.1.0
    13
    14# The modules must also appear in the build list, not just the graph.
    15go list -m all
    16stdout '^i v0.1.0'
    17
    18# The packages provided by those dependencies must resolve.
    19go list all
    20stdout '^i$'
    21
    22-- go.mod --
    23module main
    24
    25go 1.13
    26
    27require (
    28	a v0.0.0
    29	b v0.0.0
    30	c v0.0.0
    31)
    32
    33// Apply replacements so that the test can be self-contained.
    34// (It's easier to see all of the modules here than to go
    35// rooting around in testdata/mod.)
    36replace (
    37	a => ./a
    38	b => ./b
    39	c => ./c
    40	x v0.1.0 => ./x1
    41	x v0.2.0 => ./x2
    42	i => ./i
    43)
    44-- main.go --
    45package main
    46
    47import (
    48	_ "a"
    49	_ "b"
    50	_ "c"
    51)
    52
    53func main() {}
    54-- a/go.mod --
    55module a
    56go 1.13
    57require x v0.1.0
    58-- a/a.go --
    59package a
    60-- b/go.mod --
    61module b
    62go 1.13
    63require x v0.2.0
    64-- b/b.go --
    65package b
    66-- c/go.mod --
    67module c
    68go 1.13
    69-- c/c.go --
    70package c
    71import _ "i"
    72-- x1/go.mod --
    73module x
    74go1.13
    75require i v0.1.0
    76-- x2/go.mod --
    77module x
    78go1.13
    79-- i/go.mod --
    80-- i/i.go --
    81package i

View as plain text