"log"
"os"
"os/exec"
- "path"
+ "path/filepath"
"strings"
"testing"
)
defer os.RemoveAll(dir)
// Create source.
- src := path.Join(dir, "test.go")
+ src := filepath.Join(dir, "test.go")
f, err := os.Create(src)
if err != nil {
log.Fatalf("could not create source file: %v", err)
f.Close()
// Name of destination.
- dst := path.Join(dir, "test")
+ dst := filepath.Join(dir, "test")
// Compile source.
cmd := exec.Command("go", "build", "-o", dst, src)
defer os.RemoveAll(dir)
// Create source.
- src := path.Join(dir, "test.go")
+ src := filepath.Join(dir, "test.go")
f, err := os.Create(src)
if err != nil {
log.Fatalf("could not create source file: %v", err)
f.Close()
// Compile source.
- cmd := exec.Command("go", "build", "-gcflags", "-S", src)
+ cmd := exec.Command("go", "build", "-gcflags", "-S", "-o", filepath.Join(dir, "test"), src)
out, err := cmd.CombinedOutput()
if err != nil {
log.Fatalf("could not build target: %v", err)