Skip to content

Commit

Permalink
predict dlv install path using os + arch
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Luhring <[email protected]>
luhring committed May 22, 2024
1 parent 2cf5015 commit e1438e2
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions pkg/build/gobuild.go
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ import (
"fmt"
gb "go/build"
"io"
"io/fs"
"log"
"os"
"os/exec"
@@ -312,23 +311,13 @@ func getDelve(ctx context.Context, platform v1.Platform) (string, error) {
}

// find the delve binary in tmpInstallDir/bin/
delveBinary := ""
if err := filepath.WalkDir(filepath.Join(tmpInstallDir, "bin"), func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}

if !d.IsDir() && strings.Contains(d.Name(), "dlv") {
delveBinary = path
}

return nil
}); err != nil {
return "", fmt.Errorf("could not search for Delve binary: %w", err)
osArchDir := ""
if platform.OS != "" && platform.Architecture != "" {
osArchDir = fmt.Sprintf("%s_%s", platform.OS, platform.Architecture)
}

if delveBinary == "" {
return "", fmt.Errorf("could not find Delve binary in %q", tmpInstallDir)
delveBinary := filepath.Join(tmpInstallDir, "bin", osArchDir, "dlv")
if _, err := os.Stat(delveBinary); err != nil {
return "", fmt.Errorf("could not find Delve binary at %q: %w", delveBinary, err)
}

return delveBinary, nil

0 comments on commit e1438e2

Please sign in to comment.