Open dicaetano opened 3 months ago
@dicaetano Can you follow the troubleshooting step here https://github.com/golang/vscode-go/wiki/debugging#troubleshooting and share information like launch.json and how you built your debugged binary and how to attach it? It should behave almost same as delve command line tool (since it's the same backend).
@dicaetano Can you follow the troubleshooting step here https://github.com/golang/vscode-go/wiki/debugging#troubleshooting and share information like launch.json and how you built your debugged binary and how to attach it? It should behave almost same as delve command line tool (since it's the same backend).
Its pretty standard, the launch config is basically what the extension propose:
{
"version": "0.2.0",
"configurations": [
{
"name": "Connect to Delve",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "${workspaceRoot}",
"port": 2345,
"host": "127.0.0.1"
},
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/api/main.go",
"envFile": "${workspaceFolder}/variables.env",
// "logOutput": "dap",
// "showLog": true,
}
]
}
To attach, I run the follwing command to start delve and used the attach option from the launch config:
dlv debug --headless --listen=:2345 --api-version=2 ./cmd/api
Here is a GIF to demonstrate. I run both the normal debug, using the extension (first try), and them attaching to delve cli:
Hello everyone, I share the same issue. Has there been any solution for this bug?
Hello Guys! Same problem here.
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
* Run `go version` to get version of Go from _the VS Code integrated terminal_. - go1.22.0 darwin/amd64 * Run `gopls -v version` to get version of Gopls from _the VS Code integrated terminal_. - v0.15.2 * Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders. - 1.87.2 * Check your installed extensions to get the version of the VS Code Go extension - v0.41.2 * Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > `Go: Locate Configured Go Tools` command. # Tools Configuration ## Environment GOBIN: undefined toolsGopath: gopath: /Users/rcaetano/go GOROOT: /Users/rcaetano/sdk/go1.21.1 PATH: /Users/rcaetano/sdk/go1.21.1/bin:/Users/rcaetano/.pyenv/shims:/Users/rcaetano/Downloads/google-cloud-sdk/bin:/Users/rcaetano/.gvm/bin:/Users/rcaetano/.nvm/versions/node/v14.18.1/bin:/usr/local/bin:/Users/rcaetano/Library/Python/3.8/bin:/Users/rcaetano/go/bin:/Users/rcaetano/.nvm/versions/node/v14.18.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/usr/local/sbin:/usr/local/go/bin:/Users/rcaetano/.fig/bin:/Users/rcaetano/.local/bin:/Users/rcaetano/go/bin/mockery PATH (vscode launched with): /Users/rcaetano/.pyenv/shims:/Users/rcaetano/Downloads/google-cloud-sdk/bin:/Users/rcaetano/.gvm/bin:/Users/rcaetano/.nvm/versions/node/v14.18.1/bin:/usr/local/bin:/Users/rcaetano/Library/Python/3.8/bin:/Users/rcaetano/go/bin:/Users/rcaetano/.nvm/versions/node/v14.18.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/usr/local/sbin:/usr/local/go/bin:/Users/rcaetano/.fig/bin:/Users/rcaetano/.local/bin:/Users/rcaetano/go/bin/mockery ## Tools go: /Users/rcaetano/sdk/go1.21.1/bin/go: go version go1.21.1 darwin/amd64 gopls: /Users/rcaetano/go/bin/gopls (version: v0.15.2 built with go: go1.21.1) gotests: /Users/rcaetano/go/bin/gotests (version: v1.6.0 built with go: go1.22.0) gomodifytags: not installed impl: not installed goplay: /Users/rcaetano/go/bin/goplay (version: v1.0.0 built with go: go1.22.0) dlv: /Users/rcaetano/go/bin/dlv (version: v1.22.1 built with go: go1.21.1) golangci-lint: /Users/rcaetano/go/bin/golangci-lint (version: v1.56.2 built with go: go1.22.0) ## Go env Workspace Folder (fury_shipping-circuits-api): /Users/rcaetano/workspace/forecast/fury_shipping-circuits-api GO111MODULE='' GOARCH='amd64' GOBIN='' GOCACHE='/Users/rcaetano/Library/Caches/go-build' GOENV='/Users/rcaetano/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users/rcaetano/go/pkg/mod' GONOPROXY='github.com/melisource/*,github.com/mercadolibre/*' GONOSUMDB='github.com/melisource/*,github.com/mercadolibre/*' GOOS='darwin' GOPATH='/Users/rcaetano/go' GOPRIVATE='github.com/melisource/*,github.com/mercadolibre/*' GOPROXY='https://proxy.golang.org,direct' GOROOT='/Users/rcaetano/sdk/go1.21.1' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/Users/rcaetano/sdk/go1.21.1/pkg/tool/darwin_amd64' GOVCS='' GOVERSION='go1.21.1' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='clang' CXX='clang++' CGO_ENABLED='1' GOMOD='/Users/rcaetano/workspace/forecast/fury_shipping-circuits-api/go.mod' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/3h/sr1wc_pd51x2ft4fhf8kn2kwf3707j/T/go-build2089358252=/tmp/go-build -gno-record-gcc-switches -fno-common'
Share the Go related settings you have added/edited
Describe the bug
When debugging, some lines of codes are sometimes skipped when using Step Over (F10). For example, in this snipped of code (replaced the real names):
When I put a breakpoint in the first line, F10 goes to
if err
. But if I use F10 again, it does not break in the last line, it executes it, unless I put a breakpoint in it. This happens a lot, and its quite anoying. But is not in every code.I was not able to reproduce this behavior in a separated project to put in here. I copied the exact code (all the file), mocked all the dependencies, but used the same structs/entities, and still not reproduceble. Maybe this is related to the amount of memory used by my API (stack), and the debug makes some kind of optmizations? Just guessing.
When I use Delve directly, and only attach the debug into it, it works perfectly. So its a behavior of the extension I think.
Is this a possible bug, or an expected behavior? If the last, is there anything, some config, that I can change to try to fix it?
Steps to reproduce the behavior:
Not able to reproduce.