..

Fix GoLand Debug Not Work

I found GoLand debugger is not working yesterday after I upgrade my MacOS version to 11.5.2 (20G95) on my M1 based Macbook Air.

Behavior

When start GoLand debugging, it will hang forever without stopping at any breakpoint. Goland debug hang

Investigation

After some investigation I figured that GoLand is using delve for debugging which is not suprised, and directly using dlv in terminal is not working either.
dlv error

Adding debug information when launch dlv.
dlv error debug

I don’t understand every word of this error, but the invalid argument caught my attention.

I could not find useful information on Google, then I tried searching on Twitter, someone reported a similar issue https://twitter.com/Mach_XNU/status/1415986625612484613.
platform error

It seems related to platform based on his investigation, so I tried append arch -arm64 before dlv command, and magically it’s working.

Solve the Problem

Next step is to solve GoLand debug issue.

  1. first create a bash script, and save it. I use $HOME/bin/dlv
    arch -arm64 /Users/vincenthuang/go/bin/dlv "$@"
    
  2. make script executable.
    chmod +x $HOME/bin/dlv
    
  3. update GoLand configuration Open GoLand, go to Help -> Edit Custom VM Options, append a line
    -Ddlv.path=/Users/vincenthuang/bin/dlv
    

    After restart GoLand, it should work as expected.