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

Don't reuse exec.Cmd #42

Merged
merged 1 commit into from
May 18, 2021
Merged
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
4 changes: 2 additions & 2 deletions internal/builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ func GetModules(cfg Config) error {
}

cfg.Logger.Info("Getting go modules")
cmd := exec.Command(goBinary, "mod", "download")
cmd.Dir = cfg.Distribution.OutputPath

// basic retry if error from go mod command (in case of transient network error). This could be improved
// retry 3 times with 5 second spacing interval
retries := 3
failReason := "unknown"
for i := 1; i <= retries; i++ {
cmd := exec.Command(goBinary, "mod", "download")
cmd.Dir = cfg.Distribution.OutputPath
if out, err := cmd.CombinedOutput(); err != nil {
failReason = fmt.Sprintf("%s. Output: %q", err, out)
cfg.Logger.Info("Failed modules download", "retry", fmt.Sprintf("%d/%d", i, retries))
Expand Down