从Visual Studio调试Raspberry Pi中的Golang二进制文件

I am cross-compiling the following sample code from visual studio in raspberry pi(Raspbian GNU/Linux 9 stretch) using Windows 10 OS:

package main
import "fmt"
func main() {
    fmt.Println("Hello World, 世界")
}

In order to run this in raspberry pi from VScode, I am doing the following:

  • specifying env:GOARCH and env:GOOS
  • go build main.go
  • copying generated binary to raspberry pi directory
  • logging into the pi and making the binary executable
  • logging into the pi and running the binary This is working well and I am getting the desired print statement.

The problem I am facing is with debugging the code within raspberry pi from visual studio. I am able to debug the code in visual studio by installing delve, going to the current go directory in Windows, and running dlv debug main.go. However, I am completely lost on how to set breakpoint in visual studio, build and debug the code in raspberry pi?

I did look up for tutorials online and tried some, however, none of them worked for me. Any help/link/guidance would be highly appreciated.