Skip to content

Commit 69c4563

Browse files
committed
Fix Go workspace member loading from cache
When a workspace member requires another workspace member, the code should not try to load it from the module cache. Go builds workspace members (main modules) from their local directories and ignores version requirements for them. The fix filters out requirements that point to workspace members when building the module graph, both in the initial queue and when adding transitive dependencies.
1 parent 6862138 commit 69c4563

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎crates/socket-patch-core/src/vendor/go_workspace.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ impl GoWorkspace {
395395
.iter()
396396
.filter_map(|m| m.go_mod.as_deref())
397397
.flat_map(go_mod_edit::parse_required_versions)
398+
.filter(|(path, _)| self.main_module(path).is_none())
398399
.map(|(path, v)| (path, v, false))
399400
.collect();
400401
while let Some((path, version, unpruned)) = queue.pop_front() {
@@ -411,7 +412,9 @@ impl GoWorkspace {
411412
};
412413
if unpruned || !dep.pruned {
413414
for (p, v) in &dep.requires {
414-
queue.push_back((p.clone(), v.clone(), true));
415+
if self.main_module(p).is_none() {
416+
queue.push_back((p.clone(), v.clone(), true));
417+
}
415418
}
416419
}
417420
}

0 commit comments

Comments
 (0)