I have referenced the solution provided in this GitHub issue, but it does not solve my problem.
Below is my launch.json configuration:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: /?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}",
"debugAdapter": "dlv-dap"
}
]
}
The panic occurs at the beginning of the main function, but the message is not shown graphically.
How can I resolve this issue and display the panic messages correctly?
Call stacks:
runtime.fatalpanic (\usr\local\go\src\runtime\panic.go:1294)
runtime.gopanic (\usr\local\go\src\runtime\panic.go:806)
main.main (\home\welco\go\projects\test\main.go:4)
runtime.main (\usr\local\go\src\runtime\proc.go:283)
runtime.goexit (\usr\local\go\src\runtime\asm_amd64.s:1700)
I have referenced the solution provided in this GitHub issue, but it does not solve my problem. https://github/golang/vscode-go/issues/644
Below is my launch.json configuration:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}",
"debugAdapter": "dlv-dap"
}
]
}
The panic occurs at the beginning of the main function, but the message is not shown graphically.
How can I resolve this issue and display the panic messages correctly?
Call stacks:
runtime.fatalpanic (\usr\local\go\src\runtime\panic.go:1294)
runtime.gopanic (\usr\local\go\src\runtime\panic.go:806)
main.main (\home\welco\go\projects\test\main.go:4)
runtime.main (\usr\local\go\src\runtime\proc.go:283)
runtime.goexit (\usr\local\go\src\runtime\asm_amd64.s:1700)
Share
Improve this question
edited 8 hours ago
hyunseo welcome
asked 15 hours ago
hyunseo welcomehyunseo welcome
131 silver badge3 bronze badges
3
- Please do not post picture of text. – Volker Commented 15 hours ago
- @Volker What does it mean? The picture is simply to show that the PANIC message is not being displayed graphically. How can I post the content of this picture as text? – hyunseo welcome Commented 15 hours ago
- What do you mean by "ANIC message is not being displayed graphically" you got the panic and the call stack (bottom left). – Volker Commented 13 hours ago
1 Answer
Reset to default -1you can try to use
{
"version": "0.2.0",
"configurations": [{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}",
"debugAdapter": "dlv-dap",
"dlvFlags": ["--log"],
"showLog": true,
"dlvFlags": ["--log"],
"logOutput": "debugger,debug",
"showReturnValue": true
}]
}
or try to utilize recover()
func main() {
defer func() {
if r := recover(); r != nil {
fmt.Fprintf(os.Stderr, "Recovered from panic: %v\n", r)
}
}()
panic("This is a panic!")
}