Reputation: 30895
i had the vscode running and debugging GO code just fine , after i did update from within VSCode now i can't debug and i keep getting this error :
could not launch process: not an executable file
Process exiting with code: 1
configuration :
go version
go version go1.15.5 windows/amd64
dlv version
Delve Debugger
Version: 1.6.0
set GOPATH=C:\Users\foo\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\FOO~1\AppData\Local\Temp\go-build049073490=/tmp/go-build -gno-record-gcc-switches
PS C:\Dev\my\go\tests>
I dont understand what went wrong in the update?
Upvotes: 14
Views: 23007
Reputation: 31
I got this error when I pressed F5 in VSCode with a _test.go
file open. When I switched to a non-test file, I could run the program just fine.
Upvotes: 1
Reputation: 41
I experienced the same issue, caused by unregistered build tags in my test file.
In my test file I have the file tagged on line 1 as follows. This is so that I can differentiate between running all unit or integration tests:
//go:build it
I solved the issue by adding the build tag to my VSCode settings.json
:
{
"go.buildTags": "it",
}
Upvotes: 0
Reputation: 595
I was having the same issue because of package naming. The solution was to use the standard declaration for a Go main file:
package main
func main () {
// Your code + Breakpoint
}
... And then was able to debug, using the following launch.json
file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Go",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceRoot}/main.go"
}
]
}
Upvotes: 11
Reputation: 21
You're getting this error because your package name isn't the same as your main function name.
package fibonacci //this needs to be called main.
func fibonacci(c, quit chan int) {
x, y := 0, 1
for {
select {
case c <- x:
x, y = y, x+y
case <-quit:
fmt.Println("quit")
return
}
}
}
func main() {
c := make(chan int)
quit := make(chan int)
go func() {
for i := 0; i < 10; i++ {
fmt.Println(<-c)
}
quit <- 0
}()
fibonacci(c, quit)
}
Upvotes: 2
Reputation: 337
I experience the same issue as user63898 on macos. I have tried everything I could find on StackOverflow and other forums.
I even made sure to keep my main.go file open while executing debug, but still get this issue:
API server listening at: 127.0.0.1:29559
could not launch process: not an executable file
Process exiting with code
Upvotes: -1
Reputation: 1015
Addition to Jsperk answer. You also can configure launch.json
so it always starts debugging main.go
(file which have main()
function). Because call stack begins from main()
, you always will reach your breakpoint in another file.
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "main.go"
}
]
}
Upvotes: 6
Reputation: 478
In my case it was exactly what Jsperk said, I have to open the file that has the main() function in it, and only then I can press Run.
... main.go needs to remain open, if you have another file open, the test will show this error message. – Jsperk
Upvotes: 3