Problem
On Windows, a GoLand debug session shows API server listening at: 127.0.0.1:[port] and then nothing else. Breakpoints are not hit and the program prints nothing. After a click on Stop, the program output appears and the session ends with exit code 0. Run starts the same program without problems. The problem occurs in every project.
Cause [Optional]
The debug build targets 32-bit Windows (windows/386). Delve, the debugger that GoLand uses, supports only windows/amd64 and windows/arm64 programs on Windows. Delve cannot find main.main in the 32-bit program, so the program stays paused before it starts. A click on Stop resumes the program, which then prints its output and exits.
A 32-bit build comes from one of two settings. Either GOARCH=386 is set, as a Windows environment variable or with go env -w, or the Go SDK is the 32-bit (windows-386) distribution and GOARCH is not set. A 32-bit Go SDK builds 32-bit programs by default, and its go env GOHOSTARCH value is 386.
Resolution
- Close GoLand.
- Open Edit the system environment variables in Windows.
- Click Environment Variables.
- Delete the
GOARCHvariable from both User variables and System variables, if present. - Open a new terminal window.
- Run
go env GOARCHand make sure that the value isamd64. - Start GoLand and debug the program again.
If go env GOARCH still shows 386, run go env GOHOSTARCH. If that command shows amd64, the GOARCH value comes from go env -w. Run go env -u GOARCH to remove it. If the command shows 386, the Go SDK is the 32-bit distribution. Install the 64-bit (windows-amd64) Go SDK and select it in Settings | Go | GOROOT.
A 32-bit Go SDK can also debug when GOARCH=amd64 is set, because it then builds 64-bit programs. A 64-bit Go SDK removes the dependence on that setting.
For more information about Delve architecture support, see Support debugging 32bit applications. The missing error message for a 32-bit debug build is tracked in Debugger hangs after 'API server listening': no error for a windows/386 build.
Comments
0 comments
Please sign in to leave a comment.