Go Debug Delve Vs Code Error

Hello
I have a problem with trying to launch delve in VS Code.
I got this error when I launch the debug:

    Starting: C:\Users\PC\go\bin\dlv-dap.exe dap --check-go-version=false --listen=127.0.0.1:52961 from c:\Go\App
DAP server listening at: 127.0.0.1:52961
Build Error: go build -o C:\Users\PC~1\AppData\Local\Temp\__debug_bin3034027566.exe -gcflags all=-N -l .
go: updates to go.mod needed; to update it:
	go mod tidy (exit status 1)

Here is my go env:

set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\PC\AppData\Local\go-build
set GOENV=C:\Users\PC\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\PC\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\PC\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17.6
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Go\App\go.mod
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\PC~1\AppData\Local\Temp\go-build3425835977=/tmp/go-build -gno-record-gcc-switches

Did you try running go mod tidy like it says?

yes I did. It removed delve and then VS code ask me to reinstall it.
Just to mention, my current project is located here :
C:\Go\App
I am wondering if it is not a GOPATH issue ?
And then I get this message :

Starting: C:\Users\PC\go\bin\dlv-dap.exe dap --check-go-version=false --listen=127.0.0.1:55205 from c:\Go\App.vscode

DAP server listening at: 127.0.0.1:55205

Build Error: go build -o C:\Users\PC~1\AppData\Local\Temp__debug_bin1831168297.exe -gcflags all=-N -l . no Go files in c:\Go\App.vscode (exit status 1)

I changed this in the launch.json

{

"version": "0.2.0",

"configurations": [

    {

        "name": "Launch Package",

        "type": "go",

        "request": "launch",

        "mode": "auto",

        //"program": "${fileDirname}",

        "program": "${workspaceFolder}",

    }

]

}

It then launch the debugger but it exit with the following message:

Starting: C:\Users\PC\go\bin\dlv-dap.exe dap --check-go-version=false --listen=127.0.0.1:57628 from C:\Go\App
DAP server listening at: 127.0.0.1:57628
Type ‘dlv help’ for list of commands.


/ // / ___
/ // / _ / _
/
/_
////___/ v4.6.3
High performance, minimalist Go web framework
https://echo.labstack.com
_____________________________O/
O
{“time”:“2022-01-21T23:39:14.7880748+01:00”,“level”:“FATAL”,“prefix”:“echo”,“file”:“main.go”,“line”:“23”,“message”:“listen tcp :1323: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.”}
Process 31008 has exited with status 1
Detaching
dlv dap (18484) exited with code: 0

I restarted my computer and it seems to work now, however is it normal I can not run my app first and then in the same time launch a debugging session ?

Sorry, I don’t know. My development system is a 32-bit x86 and delve isn’t supported :man_shrugging:

What do you use for debugging ?

  1. Tests
  2. fmt.Printf :laughing:
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.