-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/dlv,service/dap: use randomized name as default output binary
Using a fixed path as the default output binary means that executing Delve twice in the same directory will cause the second invocation to overwrite the output binary of the first instance of Delve, making the restart command not work correctly. Fixes #3345
- Loading branch information
Showing
7 changed files
with
98 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package gobuild | ||
|
||
import ( | ||
"io/ioutil" | ||
"runtime" | ||
|
||
"github.com/go-delve/delve/pkg/logflags" | ||
) | ||
|
||
// DefaultDebugBinaryPath returns an unused file path in the current | ||
// directory named 'name' followed by a random string | ||
func DefaultDebugBinaryPath(name string) string { | ||
pattern := name | ||
if runtime.GOOS == "windows" { | ||
pattern += "*.exe" | ||
} | ||
f, err := ioutil.TempFile(".", pattern) | ||
if err != nil { | ||
logflags.DebuggerLogger().Errorf("could not create temporary file for build output: %v", err) | ||
if runtime.GOOS == "windows" { | ||
return name + ".exe" | ||
} | ||
return name | ||
} | ||
r := f.Name() | ||
f.Close() | ||
return r | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters