1
0
mirror of https://github.com/google/gops.git synced 2024-11-24 08:22:25 +02:00

keep tracefile if go binary is not found

This commit is contained in:
Rene Zbinden 2017-09-15 10:19:54 +02:00
parent f6c95cf224
commit beb8511e5a

9
cmd.go
View File

@ -65,11 +65,18 @@ func trace(addr net.TCPAddr) error {
if err != nil {
return err
}
defer os.Remove(tmpfile.Name())
if err := ioutil.WriteFile(tmpfile.Name(), out, 0); err != nil {
return err
}
fmt.Printf("Trace dump saved to: %s\n", tmpfile.Name())
// Keep tracefile if go binary is not found.
if _, err := exec.LookPath("go"); err != nil {
return nil
}
defer os.Remove(tmpfile.Name())
cmd := exec.Command("go", "tool", "trace", tmpfile.Name())
cmd.Env = os.Environ()
cmd.Stdin = os.Stdin