Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add go install support as fallback #194

Merged
merged 5 commits into from
Oct 9, 2023
Merged
Changes from 1 commit
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
19 changes: 19 additions & 0 deletions internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ func (r *Runner) Run() error {
} else {
gologger.Error().Msgf("error while installing %s: %s", toolName, err)
}

gologger.Info().Msgf("trying to install %s using go install", toolName)
if err := fallbackGoInstall(toolName); err != nil {
gologger.Error().Msgf("error while installing %s using go install: %s", toolName, err)
} else {
gologger.Info().Msgf("successfully installed %s using go install", toolName)
}

}
tool := getTool(toolName, toolList)
printRequirementInfo(tool)
Expand Down Expand Up @@ -152,6 +160,17 @@ func (r *Runner) Run() error {
return nil
}

func fallbackGoInstall(toolName string) error {
cmd := exec.Command("go", "install", "-v", fmt.Sprintf("github.com/projectdiscovery/%s/v2/cmd/%s@latest", toolName, toolName))
dogancanbakir marked this conversation as resolved.
Show resolved Hide resolved
if _, err := cmd.CombinedOutput(); err != nil {
cmd = exec.Command("go", "install", "-v", fmt.Sprintf("github.com/projectdiscovery/%s/cmd/%s@latest", toolName, toolName))
if output, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("go install failed for %s: %s", toolName, string(output))
}
}
return nil
}

func printRequirementInfo(tool *types.Tool) {
specs := getSpecs(tool)

Expand Down
Loading