mirror of
https://github.com/datarhei/core.git
synced 2025-09-27 12:22:28 +08:00
20 lines
352 B
Go
20 lines
352 B
Go
package testhelper
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
"path/filepath"
|
|
)
|
|
|
|
func BuildBinary(name, pathprefix string) (string, error) {
|
|
dir := filepath.Join(pathprefix, 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
|
|
}
|