binary should add .exe on windows
This commit is contained in:
parent
2b3100bae1
commit
b91728afd7
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@ -33,6 +34,9 @@ type LongRunCmd struct {
|
||||
func NewLongRunCmd(args []string, dir string, envs []string) *LongRunCmd {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cmd := exec.CommandContext(ctx, args[0], args[1:]...)
|
||||
if runtime.GOOS == "windows" {
|
||||
cmd = exec.CommandContext(ctx, args[0]+".exe", args[1:]...)
|
||||
}
|
||||
cmd.Dir = dir
|
||||
cmd.Env = append(os.Environ(), envs...)
|
||||
|
||||
@ -95,6 +99,9 @@ func RunShortRunCmd(args []string, dir string, envs []string) (string, error) {
|
||||
defer cancel()
|
||||
|
||||
cmd := exec.CommandContext(ctx, args[0], args[1:]...)
|
||||
if runtime.GOOS == "windows" {
|
||||
cmd = exec.CommandContext(ctx, args[0]+".exe", args[1:]...)
|
||||
}
|
||||
cmd.Dir = dir
|
||||
cmd.Env = append(os.Environ(), envs...)
|
||||
|
||||
@ -104,6 +111,9 @@ func RunShortRunCmd(args []string, dir string, envs []string) (string, error) {
|
||||
|
||||
// SearchSymbolInBinary searches if the specified symbol is compiled into the bianry
|
||||
func SearchSymbolInBinary(dir string, binary string, symbol string) (bool, error) {
|
||||
if runtime.GOOS == "windows" {
|
||||
binary = binary + ".exe"
|
||||
}
|
||||
output, err := RunShortRunCmd([]string{"go", "tool", "objdump", "-s", symbol, binary}, dir, nil)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("cannot lookup into the binary: %w", err)
|
||||
|
Loading…
Reference in New Issue
Block a user