Skip to content

Commit 1134c69

Browse files
committed
cmd/go/internal/modload: change Requirements.graph type to atomic.Pointer[cachedGraph]
1 parent 8a32354 commit 1134c69

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/cmd/go/internal/modload/buildlist.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ type Requirements struct {
7373
// nested module back into a parent module).
7474
direct map[string]bool
7575

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]
7878
}
7979

8080
// A cachedGraph is a non-nil *ModuleGraph, together with any error discovered
@@ -199,7 +199,7 @@ func (rs *Requirements) initVendor(vendorList []module.Version) {
199199
mg.g.Require(vendorMod, vendorList)
200200
}
201201

202-
rs.graph.Store(cachedGraph{mg, nil})
202+
rs.graph.Store(&cachedGraph{mg, nil})
203203
})
204204
}
205205

@@ -240,9 +240,9 @@ func (rs *Requirements) hasRedundantRoot() bool {
240240
func (rs *Requirements) Graph(ctx context.Context) (*ModuleGraph, error) {
241241
rs.graphOnce.Do(func() {
242242
mg, mgErr := readModGraph(ctx, rs.pruning, rs.rootModules)
243-
rs.graph.Store(cachedGraph{mg, mgErr})
243+
rs.graph.Store(&cachedGraph{mg, mgErr})
244244
})
245-
cached := rs.graph.Load().(cachedGraph)
245+
cached := rs.graph.Load()
246246
return cached.mg, cached.err
247247
}
248248

src/cmd/go/internal/modload/load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,7 @@ func (ld *loader) computePatternAll() (all []string) {
18371837
func (ld *loader) checkMultiplePaths() {
18381838
mods := ld.requirements.rootModules
18391839
if cached := ld.requirements.graph.Load(); cached != nil {
1840-
if mg := cached.(cachedGraph).mg; mg != nil {
1840+
if mg := cached.mg; mg != nil {
18411841
mods = mg.BuildList()
18421842
}
18431843
}

0 commit comments

Comments
 (0)