...

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

Documentation: cmd/go/testdata/script

     1# Test of go work sync in a workspace in which some dependency in the build
     2# list of 'b' (but not otherwise needed by `b`, so not seen when lazy loading
     3# occurs) actually is relevant to `a`.
     4#
     5# a -> p 1.0
     6# b -> q 1.1 -> p 1.1
     7go work sync
     8cmp a/go.mod a/want_go.mod
     9cmp b/go.mod b/want_go.mod
    10
    11-- go.work --
    12go 1.18
    13
    14use (
    15	./a
    16	./b
    17)
    18
    19-- a/go.mod --
    20go 1.18
    21
    22module example.com/a
    23
    24require (
    25	example.com/p v1.0.0
    26)
    27
    28replace (
    29	example.com/p => ../p
    30)
    31-- a/want_go.mod --
    32go 1.18
    33
    34module example.com/a
    35
    36require example.com/p v1.1.0
    37
    38replace example.com/p => ../p
    39-- a/a.go --
    40package a
    41
    42import (
    43	"example.com/p"
    44)
    45
    46func Foo() {
    47	p.P()
    48}
    49-- b/go.mod --
    50go 1.18
    51
    52module example.com/b
    53
    54require (
    55	example.com/q v1.1.0
    56)
    57
    58replace (
    59	example.com/q => ../q
    60)
    61-- b/want_go.mod --
    62go 1.18
    63
    64module example.com/b
    65
    66require (
    67	example.com/q v1.1.0
    68)
    69
    70replace (
    71	example.com/q => ../q
    72)
    73-- b/b.go --
    74package b
    75
    76import (
    77	"example.com/q"
    78)
    79
    80func Foo() {
    81	q.Q()
    82}
    83-- p/go.mod --
    84go 1.18
    85
    86module example.com/p
    87-- p/p.go --
    88package p
    89
    90func P() {}
    91-- q/go.mod --
    92go 1.18
    93
    94module example.com/q
    95
    96require example.com/p v1.1.0
    97
    98replace example.com/p => ../p
    99-- q/q.go --
   100package q
   101
   102import example.com/p
   103
   104func Q() {
   105	p.P()
   106}

View as plain text