Files
core/internal/testhelper/testhelper.go
2024-10-29 14:55:55 +01:00

22 lines
403 B
Go

package testhelper
import (
"fmt"
"os/exec"
"path/filepath"
"runtime"
)
func BuildBinary(name string) (string, error) {
_, filename, _, _ := runtime.Caller(0)
dir := filepath.Join(filepath.Dir(filename), name)
aout := filepath.Join(dir, name)
err := exec.Command("go", "build", "-o", aout, dir).Run()
if err != nil {
return "", fmt.Errorf("build command: %w", err)
}
return aout, nil
}