Skip to content

Commit 0d8e4e0

Browse files
committed
fix: record relative path when replace to local dir
1 parent d4c14b3 commit 0d8e4e0

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lang/golang/parser/parser.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@ func getDeps(dir string, goWork bool) (a map[string]string, hasGoWork bool, cgoP
224224
cgoPkgs[module.Path] = true
225225
}
226226
if module.Replace != nil {
227-
deps[module.Path] = module.Replace.Path + "@" + module.Replace.Version
227+
if module.Replace.Dir != "" {
228+
deps[module.Path] = module.Replace.Path
229+
} else {
230+
deps[module.Path] = module.Replace.Path + "@" + module.Replace.Version
231+
}
228232
} else {
229233
if module.Version != "" {
230234
deps[module.Path] = module.Path + "@" + module.Version
@@ -249,6 +253,10 @@ func (p *GoParser) ParseRepo() (Repository, error) {
249253
continue
250254
}
251255
mod := p.repo.Modules[lib.name]
256+
// if there is multi go.mod in repo and one replace to local module, the mod will be nil.
257+
if mod == nil {
258+
continue
259+
}
252260
if err := p.ParseModule(mod, filepath.Join(p.homePageDir, mod.Dir)); err != nil {
253261
return p.getRepo(), err
254262
}

0 commit comments

Comments
 (0)