Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
gopkg: include subpackages (#54)
Browse files Browse the repository at this point in the history
* gopkg: include subpackages
* gopkg: remove go files
  • Loading branch information
mcoops authored Nov 18, 2021
1 parent 4bed126 commit 19e487d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
1 change: 0 additions & 1 deletion deplist.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ func GetDeps(fullPath string) ([]Dependency, Bitmask, error) {
d := Dependency{
DepType: LangGolang,
Path: goPkg.Name,
Files: goPkg.Gofiles,
Version: goPkg.Version,
}
deps = append(deps, d)
Expand Down
20 changes: 13 additions & 7 deletions internal/scan/gopkg.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package scan

import (
"path/filepath"

"github.com/BurntSushi/toml"
log "github.com/sirupsen/logrus"
)

type GoPkgLockDeps struct {
Name string
Version string
Gofiles []string
}

type goPkg struct {
Expand Down Expand Up @@ -39,18 +40,23 @@ func GetGoPkgDeps(path string) ([]GoPkgLockDeps, error) {
ver = d.Revision
}

var files []string
if len(d.Packages) > 1 {
files = append(files, d.Packages...)
}

gathered = append(gathered,
GoPkgLockDeps{
Name: d.Name,
Version: ver,
Gofiles: files,
},
)

for _, subpackage := range d.Packages {
if subpackage != "." {
gathered = append(gathered,
GoPkgLockDeps{
Name: filepath.Join(d.Name, subpackage),
Version: ver,
},
)
}
}
}

return gathered, nil
Expand Down

0 comments on commit 19e487d

Please sign in to comment.