- What version of Delve are you using (
dlv version
)?
master
- What version of Go are you using? (
go version
)?
1.6/windows
- What operating system and processor architecture are you using?
windows 10
- What did you do?
dlv debug
- What did you expect to see?
current exe path
- What did you see instead?
error
Demo code
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
)
// execPath returns the executable path.
func execPath() (string, error) {
filePath := os.Args[0]
file, err := exec.LookPath(filePath)
if err != nil {
return "", err
}
return filepath.Abs(file)
}
func main() {
path, err := execPath()
fmt.Printf("%s-%s", path, err)
}
Problem code
exec.LookPath(os.Args[0])
Problem analysis
On Windows exec.LookPath(path)
function implementation to determine whether the path
for exe/com /..
File extension. Call the dlv debug
command will generate a debug
file , it no file extension.
Solve the problem
Modify the generated logic of the debug
file, add the exe
extension.
A simple solution, modify commands.go#L50 to :
var (
debugname = "debug"
testdebugname = "debug.test"
)
func init() {
switch os := runtime.GOOS; os {
case "windows":
debugname = "debug.exe"
testdebugname = "debug.test.exe"
}
}