對Visual Studio Code 中的Delve 調試器進行故障排除
儘管安裝了Go 擴展,但在讓Delve 調試器在Visual Studio Code 中工作時遇到問題。以下是解決此問題的逐步指南:
先決條件
- 安裝最新版本的 Go 並設定 GOROOT 和 GOPATH 環境變數。
- 將 $GOPATH/bin 加入您的作業系統 PATH 環境變數。
- 設定 GO15VENDOREXPERIMENT=1。
- 使用 go get github.com/derekparker/delve/cmd/dlv 安裝 dlv(Go 偵錯器) 。確保它在 $GOPATH/bin 中可用。
- 安裝 Visual Studio Code。
DLV 擴充與設定
- 安裝對 Visual 的 Rich Go 語言支援來自 Marketplace 的 Studio Code 擴充功能。
在 VS Code 中偵錯設定
- 在 VS Code 中開啟包含 Go 專案的資料夾(Ctrl Shift E)。
- 開啟 hello.go 檔案或建立一個新檔案。
- 在要偵錯的行上按 F9 新增斷點(例如 i := 101)。
- 按 F5開始偵錯或執行應用程式。
- 使用 F10 跳過,使用 F11 進入,使用 Shift F11 跳出程式碼區塊。
啟動設定
預設情況下,您的launch.json 設定不變:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceRoot}",
"env": {},
"args": []
}
]
}
登入後複製
結果
依照這些步驟操作後,您應該可以在Visual Studio Code 中成功使用Delve 偵錯器。
以上是為什麼我的 Delve 偵錯器無法在 Visual Studio Code 中運行?的詳細內容。更多資訊請關注PHP中文網其他相關文章!