VS Code中Go调试适配器进程意外终止,求故障排查建议
Troubleshooting "Go debug adapter process has terminated unexpectedly" in VS Code
Let’s walk through some targeted troubleshooting steps since you’ve already tried the basics (reinstalling extensions/Delve, checking environment settings):
1. Verify Delve Works Outside VS Code
First, rule out Delve itself being broken:
- Open a command prompt and run
dlv version— this should return your Delve version without errors. If it fails, reinstall Delve with:go install github.com/go-delve/delve/cmd/dlv@latest - Try launching a debug session directly with Delve:
If this works, the issue is likely tied to VS Code’s configuration; if not, Delve has installation problems related to your Go version or Windows setup.dlv debug ./your-main-file.go
2. Fix Up Your Debug Configuration
Your config snippet was cut off, so let’s cover common missteps:
- Ensure the
modefield is set to a valid value (debug,test, orexec— use"mode": "debug"for standard app launches). - Double-check the
programfield points to your main file/package. Example:"program": "${workspaceFolder}/cmd/main.go" - Add
"trace": "verbose"to your config. This will dump detailed logs to the Debug Console, showing exactly where the adapter crashes.
3. Windows-Specific Checks
Since you’re on Windows 10 x64, these are easy to miss:
- Run VS Code as Administrator — Delve sometimes needs elevated privileges to attach to processes.
- Temporarily disable antivirus/firewall. Some security tools block Delve’s process injection capabilities.
- Confirm
GOPATHandGOROOTmatch in both system environment variables and VS Code settings (go to File > Preferences > Settings and search forgo.gopath/go.goroot).
4. Address Version Compatibility
Your setup uses older versions, which often cause compatibility gaps:
- Update VS Code to the latest stable release (v1.22.2 is from 2018 and lacks modern debug adapter fixes).
- Upgrade Go to a newer version compatible with Delve — Go 1.9.1 is outdated; aim for at least Go 1.16+.
- If updating doesn’t help, roll back the Go extension to a version matched to your Go version. For Go 1.9, try extension v0.11.0 (known to work with older Go releases).
5. Reset Extension Settings
Corrupted settings can cause odd failures:
- Open the command palette (
Ctrl+Shift+P), runGo: Reset Go Extension Settings. - Restart VS Code and rebuild your debug launch config from scratch.
内容的提问来源于stack exchange,提问作者Ali Altun
相关产品推荐
相关产品推荐

