Skip to content

Commit

Permalink
feat: change the strategy for finding the go.mod file path
Browse files Browse the repository at this point in the history
  • Loading branch information
LiusCraft committed Jan 21, 2024
1 parent b9f3ec1 commit cc8262f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/proc/bininfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,17 @@ func (bi *BinaryInfo) PackagePathMap(path string) map[string]string {
if len(bi.buildModInfoMap) == 0 {
bi.buildModInfoMap = make(map[string]string)
binfo, _ := buildinfo.ReadFile(path)
bi.buildModInfoMap["main"] = filepath.ToSlash(filepath.Dir(path)) + "/"
fileSplit := strings.Split((filepath.ToSlash(filepath.Dir(path)) + "/"), "/")
for i := len(fileSplit) - 1; i > 0; i-- {
currentDir := strings.Join(fileSplit[:i], "/") + "/"
_, err := os.Open(currentDir + "go.mod")
if err == nil {
bi.buildModInfoMap["main"] = currentDir
bi.buildModInfoMap[binfo.Path] = currentDir
break
}
}

for _, m := range binfo.Deps {
aa := module.Version{
Path: m.Path,
Expand Down

0 comments on commit cc8262f

Please sign in to comment.