mirror of
https://github.com/datarhei/core.git
synced 2025-10-06 08:27:08 +08:00
22 lines
403 B
Go
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
|
|
}
|