在VScode中无法进行Golang代码的断点调试
时间:2024-03-02
浏览:486
作者:佚名
大家好,今天本人给大家带来文章《在VScode中无法进行Golang代码的断点调试》,文中内容主要涉及到,如果你对Golang方面的知识点感兴趣,那就请各位朋友继续看下去吧~希望能真正帮到你们,谢谢!
问题内容
我在调试在 golang 中完成的项目时遇到问题,该项目编译正确并完美运行,但是当我添加断点时,控制台返回以下错误。 我没有使用 rosetta。
我还成功地使用 goland (ide jetbrains) 重现了同样的问题
如果我删除断点并继续该过程,项目将继续运行而不会出现错误。问题出在 vscode 找到断点的时候。
我使用macos big sur 版本 11.3 (20e232)
我使用的 go 版本(go 版本 )?
$ go version go1.16.3 darwin/arm64
我使用什么操作系统和处理器架构(go env)?
go env 输出$ go env go111module="on" goarch="arm64" gobin="" gocache="/users/thomascaycedomartinez/library/caches/go-build" goenv="/users/thomascaycedomartinez/library/application support/go/env" goexe="" goflags="" gohostarch="arm64" gohostos="darwin" goinsecure="" gomodcache="/users/thomascaycedomartinez/go/pkg/mod" gonoproxy="" gonosumdb="" goos="darwin" gopath="/users/thomascaycedomartinez/go" goprivate="" goproxy="https://proxy.golang.org,direct" goroot="/usr/local/go" gosumdb="sum.golang.org" gotmpdir="" gotooldir="/usr/local/go/pkg/tool/darwin_arm64" govcs="" goversion="go1.16.3" gccgo="gccgo" ar="ar" cc="clang" cxx="clang++" cgo_enabled="1" gomod="/dev/null" cgo_cflags="-g -o2" cgo_cppflags="" cgo_cxxflags="-g -o2" cgo_fflags="-g -o2" cgo_ldflags="-g -o2" pkg_config="pkg-config" gogccflags="-fpic -arch arm64 -pthread -fno-caret-diagnostics -qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2x/7xq8cphj5gzc5lq2fbbl3vtw0000gn/t/go-build3536386239=/tmp/go-build -gno-record-gcc-switches -fno-common"
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "kuenta backend",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/kuenta",
"env": {
"HOSTNAME": "localhost"
},
"args": []
}
]
}
您期望看到什么?
断点应该正确工作。
正确答案
嗯,简而言之,这个问题显然是在 macOS Big Sur 11.3 (20E232) 的最新更新中出现的问题
部分解决此问题直至修复。
重建 dlv 并将其复制到临时路径。
在我的例子中添加新行的路径
dlv.path=/Users/thomascaycedomartinez/go/bin/dlv保存文件,现在就可以正常调试了。
要查看更多信息,您可以访问本期 https://github.com/go-delve/delve/issues/2436
好了,本文到此结束,带大家了解了《在VScode中无法进行Golang代码的断点调试》,希望本文对你有所帮助!关注golang学习网公众号,给大家分享更多Golang知识!
本文内容来源于互联网,如有侵权请联系删除。
近期热门
11.18
11.15
站内热门
最新文章
11.29
11.29
11.29
11.29
11.29
热门专题
