File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ func modTidyGoSum() {
75
75
// we only have to tell modfetch what needs keeping.
76
76
reqs := modload .Reqs ()
77
77
keep := make (map [module.Version ]bool )
78
+ replaced := make (map [module.Version ]bool )
78
79
var walk func (module.Version )
79
80
walk = func (m module.Version ) {
80
81
// If we build using a replacement module, keep the sum for the replacement,
@@ -87,10 +88,11 @@ func modTidyGoSum() {
87
88
keep [m ] = true
88
89
} else {
89
90
keep [r ] = true
91
+ replaced [m ] = true
90
92
}
91
93
list , _ := reqs .Required (m )
92
94
for _ , r := range list {
93
- if ! keep [r ] {
95
+ if ! keep [r ] && ! replaced [ r ] {
94
96
walk (r )
95
97
}
96
98
}
Original file line number Diff line number Diff line change 1
1
env GO111MODULE=on
2
2
3
+ # golang.org/issue/30166: 'go mod tidy' should not crash if a replaced module is
4
+ # involved in a cycle.
5
+ cd cycle
6
+ env GOTRACEBACK=off
7
+ go mod tidy
8
+ cd ..
9
+
3
10
# From inside the module, 'go list -m all' should NOT include transitive
4
11
# requirements of modules that have been replaced.
5
12
go list -m all
@@ -69,3 +76,35 @@ import (
69
76
_ "rsc.io/sampler"
70
77
_ "golang.org/x/text/language"
71
78
)
79
+
80
+ -- cycle/go.mod --
81
+ module golang.org/issue/30166
82
+
83
+ require (
84
+ golang.org/issue/30166/a v0.0.0
85
+ golang.org/issue/30166/b v0.0.0
86
+ )
87
+
88
+ replace (
89
+ golang.org/issue/30166/a => ./a
90
+ golang.org/issue/30166/b => ./b
91
+ )
92
+ -- cycle/cycle.go --
93
+ package cycle
94
+
95
+ import (
96
+ _ "golang.org/issue/30166/a"
97
+ _ "golang.org/issue/30166/b"
98
+ )
99
+ -- cycle/a/a.go --
100
+ package a
101
+ -- cycle/a/go.mod --
102
+ module golang.org/issue/30166/a
103
+
104
+ require golang.org/issue/30166/b v0.0.0
105
+ -- cycle/b/b.go --
106
+ package b
107
+ -- cycle/b/go.mod --
108
+ module golang.org/issue/30166/b
109
+
110
+ require golang.org/issue/30166/a v0.0.0
You can’t perform that action at this time.
0 commit comments