Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions resolver/gomod.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ type GoModProject struct {
Path string
Version string
Dir string
Replace *GoModProject
}

func ProjectsFromGoModFile(filename string) ([]GoModProject, error) {
cmd := exec.Command("go", "list", "-json", "-m", "all")
cmd := exec.Command("go", "mod", "download", "-json")
cmd.Dir = filepath.Dir(filename)
cmd.Stderr = os.Stderr

Expand All @@ -37,7 +36,11 @@ func ProjectsFromGoModFile(filename string) ([]GoModProject, error) {
var project GoModProject
err := jsonDec.Decode(&project)
for err == nil {
projects = append(projects, project)
if project.Dir != "" {
projects = append(projects, project)
}

project = GoModProject{}
err = jsonDec.Decode(&project)
}
if err == io.EOF {
Expand Down
11 changes: 1 addition & 10 deletions resolver/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,9 @@ func LocateGoModProjects(projects []GoModProject) (map[string]Dependency, error)
deps := make(map[string]Dependency, len(projects))

for _, project := range projects {
if strings.HasPrefix(project.Path, "github.com/stackrox/") {
continue
}

version := project.Version
if project.Replace != nil && project.Replace.Path == project.Path {
version = project.Replace.Version
}

dep := Dependency{
Name: project.Path,
Version: version,
Version: project.Version,
SourceDir: project.Dir,
}
deps[dep.Name] = dep
Expand Down