@@ -73,8 +73,8 @@ type Requirements struct {
73
73
// nested module back into a parent module).
74
74
direct map [string ]bool
75
75
76
- graphOnce sync.Once // guards writes to (but not reads from) graph
77
- graph atomic.Value // cachedGraph
76
+ graphOnce sync.Once // guards writes to (but not reads from) graph
77
+ graph atomic.Pointer [ cachedGraph ]
78
78
}
79
79
80
80
// A cachedGraph is a non-nil *ModuleGraph, together with any error discovered
@@ -199,7 +199,7 @@ func (rs *Requirements) initVendor(vendorList []module.Version) {
199
199
mg .g .Require (vendorMod , vendorList )
200
200
}
201
201
202
- rs .graph .Store (cachedGraph {mg , nil })
202
+ rs .graph .Store (& cachedGraph {mg , nil })
203
203
})
204
204
}
205
205
@@ -240,9 +240,9 @@ func (rs *Requirements) hasRedundantRoot() bool {
240
240
func (rs * Requirements ) Graph (ctx context.Context ) (* ModuleGraph , error ) {
241
241
rs .graphOnce .Do (func () {
242
242
mg , mgErr := readModGraph (ctx , rs .pruning , rs .rootModules )
243
- rs .graph .Store (cachedGraph {mg , mgErr })
243
+ rs .graph .Store (& cachedGraph {mg , mgErr })
244
244
})
245
- cached := rs .graph .Load ().( cachedGraph )
245
+ cached := rs .graph .Load ()
246
246
return cached .mg , cached .err
247
247
}
248
248
0 commit comments